-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStartVMs.ps1
More file actions
28 lines (23 loc) · 1.23 KB
/
StartVMs.ps1
File metadata and controls
28 lines (23 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
workflow StartVMs
{
#Runbook hashed together by Steve Winwood
#By default, errors in PowerShell do not cause workflows to suspend, like exceptions do.
# This means a runbook can still reach 'completed' state, even if it encounters errors
# during execution. The below command will cause all errors in the runbook to be thrown as
# exceptions, therefore causing the runbook to suspend when an error is hit.
$ErrorActionPreference = "Stop"
# Grab the credential to use to authenticate to Azure.
$Cred = Get-AutomationPSCredential -Name "[insert Azure automation user here]"
# Connect to Azure
Add-AzureAccount -Credential $Cred | Write-Verbose
# Select the Azure subscription you want to work against
Select-AzureSubscription -SubscriptionName "[insert subscription name here" | Write-Verbose
# Start the VMs
Start-AzureVM -Name [name of VM] -ServiceName [name of Cloud Service]
# multiple start VM commands can be listed here
}
# Preliminary steps
# 1 Create Azure Automation Instance
# 2 Create Azure user to be used to authenticate automation and set password by logging into web portal
# 3 Create Credential (Asset) for this user under the Azure automation instance
# 4 Create Schedule (Asset) under the Azure automation instance