Get-MgmtGraphContext
MgmtGraph: Audits the current Microsoft Graph connection context
#Requires -Version 5.1
#Requires -Modules Microsoft.Graph.Authentication
[CmdletBinding()]
Param ()
Process {
try {
$context = Get-MgContext -ErrorAction Stop
if (-not $context) {
Write-Warning "No active Microsoft Graph context found. Please connect first."
return
}
$result = [PSCustomObject]@{
Account = $context.Account
TenantId = $context.TenantId
Environment = $context.Environment
Scopes = $context.Scopes
AuthType = $context.AuthType
CertificateThumbprint = $context.CertificateThumbprint
Timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
}
Write-Output $result
}
catch {
throw
}
}This script has no configurable parameters.