DESCRIPTION
This PowerShell Runbook (compatible with PowerShell Core) connects to Azure using an Automation Run As account, retrieves the power status of VMs and turns off / on in sequence those that are turned on / off. You can attach a recurring schedule to this runbook to run it at a specific time.
REQUIRED
-
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.
-
An Action input parameter value that allows runbook to handle VMs power state. The parameter must be set to 'Stop' or 'Start'.
-
All the following PowerShell modules are required to run the cmdlets : Az.Accounts, Az.Resources, Az.Compute and Az.Automation.
OPTIONAL
-
A TagName input parameter value that allows scoping the VMs to only tagged VMs.
-
A TagValue input parameter value that allows scoping the VMs to a particular tag value.
AUTHOR
Farouk FRIHA
LAST EDIT
2019-19-05
RELEASE NOTES
2019-19-05 First release
2019-19-05 Handle changes to parameters
RUNBOOK CONTENT
** **
** **
** **
Note: TechNet gallery is retiring! This script was migrated from TechNet script center to GitHub by Microsoft Azure Automation product group.