Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $connectionName = "AzureRunAsConnection"
- try
- {
- # Get the connection "AzureRunAsConnection "
- $servicePrincipalConnection=Get-AutomationConnection -Name $connectionName
- "Logging in to Azure..."
- Connect-AzureAD `
- -TenantId $servicePrincipalConnection.TenantId `
- -ApplicationId $servicePrincipalConnection.ApplicationId `
- -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
- }
- catch {
- if (!$servicePrincipalConnection)
- {
- $ErrorMessage = "Connection $connectionName not found."
- throw $ErrorMessage
- } else{
- Write-Error -Message $_.Exception
- throw $_.Exception
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement