Private/Connect-Purview.ps1
|
# Connect-Purview.ps1 # Authenticates to the Security and Compliance Center (IPPS). # Part of the M365-QuickAssess module -- not exported. function Connect-Purview { Write-Log "Checking Purview connection..." # ------------------------------------------------------------------- # If already connected, skip # ------------------------------------------------------------------- try { $null = Get-Command Get-RetentionCompliancePolicy -ErrorAction Stop Get-RetentionCompliancePolicy -ErrorAction Stop | Out-Null Write-Log "Purview already connected" return } catch { # Not connected -- fall through to connect below } # ------------------------------------------------------------------- # Connect # ------------------------------------------------------------------- Write-Log "Connecting to Purview (Compliance Center)..." try { Connect-IPPSSession ` -UserPrincipalName $script:Context.GraphAccount ` -ShowBanner:$false ` -ErrorAction Stop Write-Log "Connected to Purview" } catch { Write-Log "Purview connection failed: $( $_.Exception.Message )" "ERROR" throw } } |