Created
May 13, 2021 22:18
-
-
Save ejdyksen/831f064cde7b5aa53112de2f2dc75807 to your computer and use it in GitHub Desktop.
Start a VM from Azure Automation
This file contains hidden or 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
## Get the Azure Automation Acount Information | |
$azConn = Get-AutomationConnection -Name 'AzureRunAsConnection' | |
## Add the automation account context to the session | |
Add-AzureRMAccount -ServicePrincipal -Tenant $azConn.TenantID -ApplicationId $azConn.ApplicationId -CertificateThumbprint $azConn.CertificateThumbprint | |
## Get the Azure VMs with tags matching the value '6am' | |
$azVMs = Get-AzureRMVM | Where-Object {$_.Name -eq 'VM_NAME_HERE'} | |
## Start VMs | |
$azVMS | Start-AzureRMVM |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment