This Graphical PowerShell runbook connects to Azure and stops all V2 VMs in an Azure subscription or resource group or a single named V2 VM.You can attach a recurring schedule to this runbook to run it at a specific time. 


1. An Automation connection asset called AzureRunAsConnection that contains the information for connecting with Azure using a service principal.  To use an asset with a different name you can pass the asset name as a input parameter to this runbook or change the default value for the AzureConnectionAssetName input parameter.


2. A ResourceGroupName input parameter value that allows scoping the V2 VMs to a particular resource group.3. A VMName input parameter that allows specification of a single V2 VM.

- Link Conditions to determine how to get the VMs -Following the 'Connect to Azure' activity there are three sequence links that have conditions set.  These conditions are mutually exclusive and will direct the workflow to only one of the connected activities to get VMs.
- Merge VMs activity -The 'Merge VMs' activity is used to merge the output of the immediately preceding activities.  By merging the output into a single activity, which then re-outputs the objects, the downstream activities, like 'Stop VM'  are able to refer to a single activity for input data.  At design time, we don't know which of the immediately preceding activities will run, so 'Stop VM' doesn't know which activity to refer to for input data.  By creating 'Merge VMs', 'Stop VM' has a single activity to refer to for input.


System Center Automation Team 




2016-5-9 First release

2016-10-22 Handle changes to the output object properties from Stop-AzureRmVm


Graphical Runbook
This is a graphical runbook.