Public/Get-VMetricContext.ps1

function Get-VMetricContext {
    <#
    .SYNOPSIS
    Shows where you are signed in.
 
    .DESCRIPTION
    Get-VMetricContext answers the current context: the console's address (ConsoleUrl, where the browser signs
    in) and the API's (ApiUrl, where every request goes), the account, the tenant, how you signed in, whether
    certificate checks are off, and when the access token expires (it refreshes itself). It writes nothing
    when you are not connected. It never shows a token.
 
    .PARAMETER ListAvailable
    Every session this PowerShell session holds (one per sign-in: Connect-VMetric to another console or
    tenant adds one, Set-VMetricContext replaces the current one), the current one first.
 
    .EXAMPLE
    Get-VMetricContext
 
    .EXAMPLE
    Get-VMetricContext -ListAvailable
 
    .OUTPUTS
    VirtualMetric.Context
 
    .LINK
    Connect-VMetric
 
    .LINK
    Set-VMetricContext
    #>

    [CmdletBinding()]
    [OutputType('VirtualMetric.Context')]
    param(
        [switch] $ListAvailable
    )

    if ($ListAvailable) {
        foreach ($session in (Get-VMetricCachedSession)) {
            ConvertTo-VMetricContextObject -Session $session
        }
        return
    }
    $session = Get-VMetricSession -Optional
    if ($session) {
        ConvertTo-VMetricContextObject -Session $session
    }
}