Created
September 23, 2016 01:23
-
-
Save marckean/4d4ea168c3ba773e74b5e7c950311182 to your computer and use it in GitHub Desktop.
This file contains 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
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