Az.Automation Module
The Az.Automation module provides cmdlets to manage Azure Automation accounts and their resources.
Overview
Azure Automation is a cloud-based automation and configuration service that helps manage the complex and repetitive tasks involved in managing your cloud and enterprise environments. The Az.Automation PowerShell module allows you to interact with Azure Automation resources programmatically.
Key Cmdlets
                Get-AzAutomationAccount
                
            Retrieves one or more Automation accounts.
Get-AzAutomationAccount
Get-AzAutomationAccount -ResourceGroupName "MyResourceGroup"
Get-AzAutomationAccount -Name "MyAutomationAccount" -ResourceGroupName "MyResourceGroup"
                New-AzAutomationAccount
                
            Creates a new Automation account.
New-AzAutomationAccount -ResourceGroupName "MyResourceGroup" -Name "MyNewAutomationAccount" -Location "East US"
                Remove-AzAutomationAccount
                
            Deletes an Automation account.
Remove-AzAutomationAccount -ResourceGroupName "MyResourceGroup" -Name "MyAutomationAccountToDelete"
                Set-AzAutomationAccount
                
            Updates an existing Automation account.
Set-AzAutomationAccount -ResourceGroupName "MyResourceGroup" -Name "MyAutomationAccount" -Sku "Basic"
                Get-AzAutomationRunbook
                
            Retrieves one or more runbooks from an Automation account.
Get-AzAutomationRunbook -ResourceGroupName "MyResourceGroup" -AutomationAccountName "MyAutomationAccount"
                Publish-AzAutomationRunbook
                
            Publishes a draft runbook to be runnable.
Publish-AzAutomationRunbook -ResourceGroupName "MyResourceGroup" -AutomationAccountName "MyAutomationAccount" -Name "MyRunbook"Common Parameters
Most cmdlets in this module accept the following common parameters:
| Parameter | Description | Required | 
|---|---|---|
| -ResourceGroupName | The name of the resource group. | Yes | 
| -AutomationAccountName | The name of the Automation account. | Yes | 
| -Name | The name of the specific resource (e.g., runbook, variable). | No | 
| -Location | The Azure region where the resource resides or will be created. | No | 
| -Force | Suppresses confirmation messages. | No | 
Examples
Create and Manage an Automation Account
# Create a resource group
New-AzResourceGroup -Name "MyAutomationRG" -Location "East US"
# Create a new Automation account
New-AzAutomationAccount -ResourceGroupName "MyAutomationRG" -Name "MyDemoAutomationAccount" -Location "East US"
# Get all Automation accounts in the resource group
Get-AzAutomationAccount -ResourceGroupName "MyAutomationRG"
# Delete the Automation account
# Remove-AzAutomationAccount -ResourceGroupName "MyAutomationRG" -Name "MyDemoAutomationAccount" -ForceWorking with Runbooks
# Get all runbooks in an Automation account
Get-AzAutomationRunbook -ResourceGroupName "MyAutomationRG" -AutomationAccountName "MyDemoAutomationAccount"
# Retrieve a specific runbook
Get-AzAutomationRunbook -ResourceGroupName "MyAutomationRG" -AutomationAccountName "MyDemoAutomationAccount" -Name "MySampleRunbook"
# Publish a draft runbook
# Publish-AzAutomationRunbook -ResourceGroupName "MyAutomationRG" -AutomationAccountName "MyDemoAutomationAccount" -Name "MyDraftRunbook"