Powershelll script in updatemanagement as pre check

Azure-learning 56 Reputation points

I am trying to add pre-post script in update management schedule. I created a automation run book to host pre-post script (.ps1). I am using identity for authentication.

I updated below section-
New-AzAutomationSoftwareUpdateConfiguration -ResourceGroupName "$rg" -AutomationAccountName "$automationaccount"
-Schedule "$schedule" -Duration $(new-timespan -hours 2)
-PreTaskRunbookName "precript" -PreTaskRunbookParameter @{Parameter1 ="abc"} -AzureVMResourceId $machine `
-IncludedUpdateClassification $windows

1 - It's giving me below error -
The term '-PreTaskRunbookName' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Can you please suggest on this. -PreTaskRunbookName is as per Microsoft documenetation

2- also please advise if I can use a generic script to check the vm health which is taking input from a excel file and checking VM status . or will pre/post script take VM information from Update management directly . any specific format I need to follow for pre/post script

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,143 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,297 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Maxim Sergeev 6,566 Reputation points Microsoft Employee

    Hi there,

    1. Could you please check, your azure automation account has the required Module:Az.Automation to run this CMD-let?
    2. You can use pre\post scripts whetever you want to use. It's not tied with Update Management only