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, whether new PowerShell windows sign in with it (Persisted), and when the access token expires (it refreshes itself). It writes nothing when you are not connected. It never shows a token. In a new window where a sign-in was kept for new windows (Connect-VMetric -Persist, Save-VMetricContext), it signs in with that sign-in first, as any VirtualMetric cmdlet run first does; AuthMethod then says SavedSignIn. .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 .LINK Save-VMetricContext #> [CmdletBinding()] [OutputType('VirtualMetric.Context')] param( [switch] $ListAvailable ) # In a window that has not signed in, the saved sign-in is used first, if there is one. $session = Get-VMetricSession -Optional if ($ListAvailable) { foreach ($held in (Get-VMetricCachedSession)) { ConvertTo-VMetricContextObject -Session $held } return } if ($session) { ConvertTo-VMetricContextObject -Session $session } } |