Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
workflow Shutdown_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