Private/Auth/Test-GraphConnection.ps1
|
# Copyright (c) 2026 Sandy Zeng. All rights reserved. # Source-available. All rights reserved. See LICENSE file. <# Test-GraphConnection.ps1 — Returns whether an active Microsoft Graph context exists. Author: Sandy Zeng Project: IntuneDiff Version History: 1.0.0 Initial release. #> function Test-GraphConnection { <# .SYNOPSIS Returns $true if there is an active Microsoft Graph context. #> [CmdletBinding()] [OutputType([bool])] param() if (-not (Get-Command -Name Get-MgContext -ErrorAction SilentlyContinue)) { return $false } try { $ctx = Get-MgContext -ErrorAction Stop return [bool]$ctx } catch { return $false } } |