Created
January 14, 2015 11:17
-
-
Save kerslake/5e748d5e784428759dc3 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 Stop-VM | |
{ | |
Param ( | |
[parameter(Mandatory=$true)] | |
[String] | |
$VMName, | |
[parameter(Mandatory=$true)] | |
[String] | |
$ServiceName | |
) | |
$day = (Get-Date).DayOfWeek | |
if ($day -eq 'Saturday' -or $day -eq 'Sunday'){ | |
exit | |
} | |
$subscriptionName = Get-AutomationVariable -Name "SubscriptionName" | |
$subscriptionID = Get-AutomationVariable -Name "SubscriptionID" | |
$certificateName = Get-AutomationVariable -Name "CertificateName" | |
$certificate = Get-AutomationCertificate -Name $certificateName | |
Set-AzureSubscription -SubscriptionName $subscriptionName -SubscriptionId $subscriptionID -Certificate $certificate | |
Select-AzureSubscription $subscriptionName | |
Stop-AzureVM -Name $VMName -ServiceName $ServiceName -Force | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment