Last active
November 19, 2023 07:23
-
-
Save LauraKokkarinen/02ec923de4fcde355ffa749e4842a165 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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