Skip to content

Instantly share code, notes, and snippets.

@kerslake
Created January 14, 2015 11:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kerslake/5e748d5e784428759dc3 to your computer and use it in GitHub Desktop.
Save kerslake/5e748d5e784428759dc3 to your computer and use it in GitHub Desktop.
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