Private/Set-MIASession.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Private function to set the script-level session
# variables needed for subsequent REST API calls.
# Currently this in the token and hostname, but
# could also include the refresh token.
function Set-MIASession
{
    [CmdletBinding()]
    param (
        [string]$Hostname,
        [psobject]$Response
    )

    $Script:MIASession = [PSCustomObject]@{
        Hostname = $Hostname
        Token = $Response.access_token
        CreatedAt = $(Get-Date)
        ExpiresIn = $Response.expires_in
        RefreshToken = $Response.refresh_token
    }

    #$Script:MIAHostname = $Hostname
    #$Script:MIAToken = $Response.access_token
}