Skip to content

Instantly share code, notes, and snippets.

@marckean
Last active September 23, 2016 01:23
Show Gist options
  • Save marckean/e49d90e0ac74e65d729e55c1088df1c5 to your computer and use it in GitHub Desktop.
Save marckean/e49d90e0ac74e65d729e55c1088df1c5 to your computer and use it in GitHub Desktop.
workflow Startup_VM
{
$Cred = Get-AutomationPSCredential -Name "Credential_Name"
$tenant = Get-AutomationVariable -Name "tenant"
Login-AzureRmAccount -Credential $Cred -ServicePrincipal -TenantId $tenant
$subscription = Get-AutomationVariable -Name "subscription"
Select-AzureRmSubscription -SubscriptionName $subscription
$VMs = Get-AzureRmVM | where {$_.Name -match 'Virtual_Machine_Name'}
ForEach -Parallel ($VM in $VMs)
{
Stop-AzureRmVM -Name $VM.Name -ResourceGroupName $VM.ResourceGroupName -Force
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment