Created
January 10, 2019 15:26
-
-
Save wsmelton/4f9f07a3cb02506769a36d5aa6bf47e6 to your computer and use it in GitHub Desktop.
Basic template for any runbook in Azure Automation to connect to subscription and access other resources
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
#region Az Connection | |
$RunAsCn = Get-AutomationConnection -Name "AzureRunAsConnection" | |
$cnParams = @{ | |
"ServicePrincipal" =$true; | |
"TenantID" =$RunAsCn.TenantID; | |
"ApplicationId" =$RunAsCn.ApplicationID; | |
"CertificateThumbprint" =$RunAsCn.CertificateThumbprint; | |
} | |
$null = Connect-AzureRmAccount @cnParams | |
$null = Set-AzureRmContext -SubscriptionId $RunAsCn.SubscriptionID > $null | |
$endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment