Skip to content

Instantly share code, notes, and snippets.

@fabriciosanchez
Created December 11, 2015 19:39
Show Gist options
  • Save fabriciosanchez/57f3ae2f598a5c48d115 to your computer and use it in GitHub Desktop.
Save fabriciosanchez/57f3ae2f598a5c48d115 to your computer and use it in GitHub Desktop.
workflow StartVM
{
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
Start-AzureVM -Name $VMName -ServiceName $ServiceName
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment