Skip to content

Instantly share code, notes, and snippets.

@ejdyksen
Created May 13, 2021 22:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ejdyksen/831f064cde7b5aa53112de2f2dc75807 to your computer and use it in GitHub Desktop.
Save ejdyksen/831f064cde7b5aa53112de2f2dc75807 to your computer and use it in GitHub Desktop.
Start a VM from Azure Automation
## 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