Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LauraKokkarinen/02ec923de4fcde355ffa749e4842a165 to your computer and use it in GitHub Desktop.
Save LauraKokkarinen/02ec923de4fcde355ffa749e4842a165 to your computer and use it in GitHub Desktop.
$tenant = $env:Tenant
$clientId = $env:ClientId
$certificateBase64Encoded = $env:Certificate
try {
$certificate = [System.Security.Cryptography.X509Certificates.X509Certificate2]([System.Convert]::FromBase64String($certificateBase64Encoded))
Connect-IPPSSession -Organization $tenant -AppID $clientId -Certificate $certificate
# Execute the Security & Compliance PowerShell commands you want here
}
catch {
# Implement error handling here
throw $_
}
finally {
Disconnect-ExchangeOnline -Confirm:$false
Get-PSSession | Remove-PSSession
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment