'Azure Automation - Unable to select pre-script if requires parameters
If I select a pre-script that requires parameters (mandatory or optional) for an update management deployment, the OK button is greyed out, and I cannot save the deployment.
I have tried adding a sample script from the gallery (e.g., "Update Management - Run Script Locally") still cannot save the deployment.
Creating a new automation account did not help. It seems to be a general issue. Here is another user with the same behaviour.
Solution 1:[1]
This product bug is fixed. Please try and let me know if you still face any issue.
Solution 2:[2]
Apologies for the inconvenience caused. This is a known issue and the accountable product team is working on it. The ETA for this product bug fix is end of March 2022.
Until then, please leverage the below provided workaround.
It is possible to use PowerShell instead of the Azure Portal user interface to create a new Software Update Configuration that takes a pre/post-script using parameters. Below is the code sample to do so:
$startTime = [DateTimeOffset]"2022-02-13T21:00"
$targetMachines = @(
"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxx/providers/Microsoft.Compute/virtualMachines/VM01",
"/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/xxxx/providers/Microsoft.Compute/virtualMachines/VM02")
$duration = New-TimeSpan -Hours 2
$schedule = New-AzAutomationSchedule -ResourceGroupName "ResourceGroupName" `
-AutomationAccountName "AutomationAccountName" `
-Name "MyWeeklySchedule" `
-StartTime $startTime `
-DaysOfWeek Saturday `
-WeekInterval 1 `
-ForUpdateConfiguration
New-AzAutomationSoftwareUpdateConfiguration -ResourceGroupName "ResourceGroupName" `
-AutomationAccountName "AutomationAccountName" `
-Schedule $schedule `
-Windows `
-AzureVMResourceId $targetMachines `
-IncludedUpdateClassification Critical `
-Duration $duration `
-PreTaskRunbookName "TestParameterRunbook"`
-PreTaskRunbookParameter @{Parameter1 ="test"; Parameter2 ="test"}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | KrishnaG-MSFT |
| Solution 2 |

