Skip to content

Instantly share code, notes, and snippets.

@marckean
Last active September 21, 2016 23:36
Show Gist options
  • Save marckean/6dfe901ff11586a655cc9a26cc0d5847 to your computer and use it in GitHub Desktop.
Save marckean/6dfe901ff11586a655cc9a26cc0d5847 to your computer and use it in GitHub Desktop.
workflow StopAzurePlaylistVMs
{
$Cred = Get-AutomationPSCredential -Name "PowerShell SvcAcct"
Login-AzureRmAccount -Credential $Cred
$subscription = Get-AutomationVariable -Name "subscription"
Select-AzureRmSubscription -SubscriptionName $subscription
$VMs = Get-AzureRmVM | where {$_.Name -match 'playlist'}
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