Start some VMs in a Subscription
workflow StartADVMs
{
$Cred = Get-AutomationPSCredential -Name 'admad'
Add-AzureAccount -Credential $Cred
Select-AzureSubscription -SubscriptionName "MYSubscriptionName"
Get-AzureVM -Name "ad1" -ServiceName "dcs-01" | Start-AzureVM
Get-AzureVM -Name "ad2" -ServiceName "dcs-01" | Start-AzureVM
Get-AzureVM -Name "ad3" -ServiceName "dcs-01" | Start-AzureVM
Get-AzureVM -Name "ad4" -ServiceName "dcs-01" | Start-AzureVM
}
Start all VMs in a Subscription
workflow StartAllVMs
{
$Cred = Get-AutomationPSCredential -Name 'admad'
Add-AzureAccount -Credential $Cred
Select-AzureSubscription -SubscriptionName "MYSubscriptionName"
$VMS = Get-AzureVM
foreach($VM in $VMS)
{
$VMName = $VM.Name
Start-AzureVM -ServiceName $VM.ServiceName -Name $VM.Name -Force
Write-Output "Starting VMs : $VMName "
}
}
No comments:
Post a Comment