Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. $connectionName = "AzureRunAsConnection"
  2. try
  3. {
  4. # Get the connection "AzureRunAsConnection "
  5. $servicePrincipalConnection=Get-AutomationConnection -Name $connectionName
  6.  
  7. "Logging in to Azure..."
  8. Connect-AzureAD `
  9. -TenantId $servicePrincipalConnection.TenantId `
  10. -ApplicationId $servicePrincipalConnection.ApplicationId `
  11. -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
  12. }
  13. catch {
  14. if (!$servicePrincipalConnection)
  15. {
  16. $ErrorMessage = "Connection $connectionName not found."
  17. throw $ErrorMessage
  18. } else{
  19. Write-Error -Message $_.Exception
  20. throw $_.Exception
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement