Modify Automation Start / Stop for VMs in Azure

First connect to Azure

Connect-AzAccount
$tenantId = (Get-AzContext).Tenant.Id

Get all information about Automation Accounts

Get-AzAutomationVariable -Name External_ExcludeVMNames -AutomationAccountName Automation-Account1 -ResourceGroupName RG1

To get Automation Account Name or Resoruce Group, use following commands

  • Get-AzAutomationAccount
  • Get-AzResourceGroup

Set exclude for VM “VM-SRV-01”

Get-AzAutomationVariable -Name External_ExcludeVMNames -AutomationAccountName Automation-Account-1 -ResourceGroupName RG1 | Set-AzAutomationVariable -Value 'VM-SRV-01'

Leave a Reply

Your email address will not be published.