Public/Connect-NSPEntraPairingGraph.ps1
|
function Connect-NSPEntraPairingGraph { <# .SYNOPSIS Connects to one named tenant with the pairing module's scopes. .DESCRIPTION With -TenantId, connects to that tenant. Without it, Graph sign-in selects the tenant; Get-NSPEntraPairingEnvironment discovers it and the wizard shows it before inventory. Installs Microsoft.Graph.Authentication through NSP.Bootstrap when it is missing and NSP.Bootstrap is available. -Purpose chooses the scopes. Read, the default, covers inventory and review. Preflight adds what Test-NSPEntraUserHardMatch reads. HardMatch adds the write, for Set-NSPEntraUserHardMatch. Scopes only permit: the signed-in account also needs an Entra role that can do the same thing. See the README. .EXAMPLE Connect-NSPEntraPairingGraph -TenantId '00000000-0000-0000-0000-000000000000' .EXAMPLE Connect-NSPEntraPairingGraph -TenantId '00000000-0000-0000-0000-000000000000' -Purpose Preflight #> [CmdletBinding()] param( [guid]$TenantId, [ValidateSet('Read', 'Preflight', 'HardMatch')][string]$Purpose = 'Read' ) Import-NSPM365Graph $connect = @{ Scopes = @(Get-NSPEntraPairingGraphScopes -Purpose $Purpose); Connect = $true } if ($PSBoundParameters.ContainsKey('TenantId')) { if ($TenantId -eq [guid]::Empty) { throw 'TenantId cannot be empty.' } $connect.TenantId = [string]$TenantId } Connect-NSPGraph @connect } |