Install Multiple Modules in Azure Automation With Azure PowerShell

In this blog post, we will discuss how to install multiple modules in Azure Automation with Azure PowerShell.

As your Azure Automation account grows, it becomes necessary to install multiple modules to manage your resources efficiently. Azure PowerShell is a powerful tool that enables you to automate your processes by installing and updating modules in your Azure Automation account.

First, you need to connect to Azure using PowerShell. Open PowerShell on your local machine and run the following command:



The script below will install 3 PowerShell modules into an Azure automation account. To add more modules simply, add more modules using the same format and run.


$moduleList = @(
        Name = "Az.Accounts"
        Version = "2.12.1"
        Name = "Az.Compute"
        Version = "5.5.0"
        Name = "Az.Storage"
        Version = "5.4.1"

# Iterate through the module list and install each module
foreach ($moduleItem in $moduleList) {
    $moduleName = $moduleItem.Name
    $moduleVersion = $moduleItem.Version
    $moduleContentLink = $moduleItem.ContentLink

    Write-Host "Installing $moduleName version $moduleVersion..."

    New-AzAutomationModule -ResourceGroupName $rg `
                           -AutomationAccountName $automationAccountName `
                           -Name $moduleName `
                           -ContentLink "$moduleName/$moduleVersion"

        do {
              $module = Get-AzAutomationModule -ResourceGroupName $rg `
               -AutomationAccountName $automationAccountName `
               -Name $moduleName
              Start-Sleep -Seconds 10
           } while ($module.ProvisioningState -ne "Succeeded")
    Write-Host "Installed $moduleName successfully."

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.