Need to trigger the Update from Azure Update Manager within single action

Robin Hitch 165 Reputation points
2024-12-02T05:46:39.54+00:00

I need to trigger updates from Azure Update Manager with a single action.

Specifically, I need to trigger updates for a target computer, a group, all computers, or a list of computers by copying and pasting hostnames into a text box. This could potentially be done using a PowerShell script to pass a CSV file to trigger the AUM update.

I want to trigger the updates based on specific requirements by passing hostnames or group names, rather than doing the process manually. I would appreciate any suggestions for possible solutions.

Thanks in advance.

Azure Update Manager
Azure Update Manager
An Azure service to centrally manages updates and compliance at scale.
329 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pavan Minukuri 915 Reputation points Microsoft Vendor
    2024-12-02T17:30:48.3566667+00:00

    Hi Robin Hitch
    Welcome to Microsoft Q&A, Thanks asking question here...!
    To automate the process of triggering updates in Azure Update Manager (AUM) for a target computer, a group, all computers, or a list of computers using PowerShell, you can leverage Azure Automation and the Az module. Here is an approach to achieve this:

    1.Create a PowerShell script that will read hostnames from a CSV file and trigger updates for those computers.

    # Import the Az module
    Import-Module Az
    
    # Authenticate to Azure
    Connect-AzAccount
    
    # Define the resource group and automation account
    $resourceGroupName = "YourResourceGroupName"
    $automationAccountName = "YourAutomationAccountName"
    
    # Function to trigger updates for a specific computer
    function Trigger-Update($computerName) {
        $jobParams = @{
            ResourceGroupName = $resourceGroupName
            AutomationAccountName = $automationAccountName
            ConfigurationName = "UpdateManagement"
            Parameters = @{
                ComputerName = $computerName
            }
        }
    
        $job = Start-AzAutomationDscNodeConfiguration @jobParams
        Write-Output "Triggered update for $computerName. Job ID: $($job.JobId)"
    }
    
    # Read hostnames from CSV file
    $computers = Import-Csv -Path "C:\path\to\hostnames.csv"
    
    # Trigger updates for each computer
    foreach ($computer in $computers) {
        Trigger-Update -computerName $computer.Hostname
    

    2.Ensure your CSV file (e.g., hostnames.csv) has a format like this.
    Hostname
    computer1.domain.com
    computer2.domain.com
    group1
    group2

    3.Save the script to a .ps1 file and execute it in PowerShell. Make sure the path to the CSV file is correct.
    4.For groups, you may need to add additional logic in the Trigger-Update function to handle group-specific updates. For all computers, you might want to list all computers in your Azure Update Manager setup and trigger updates for each.

    # Example: Trigger updates for all computers in a specific group
    function Trigger-UpdateForGroup($groupName) {
        $computersInGroup = Get-ComputersInGroup -groupName $groupName  # Define this function based on your setup
        foreach ($computer in $computersInGroup) {
            Trigger-Update -computerName $computer
        }
    }
    

    5.schedule this PowerShell script to run at specific intervals using Azure Automation or Windows Task Scheduler to ensure updates are triggered automatically.

    Please read attached links:

    Using this approach, you can automate the process of triggering updates in Azure Update Manager for specific computers, groups, or lists of computers, thereby eliminating the need for manual intervention.

    Please let me know if anything required.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.