You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When your update deployment is complete, you can go to **Update deployments** to view the results. As you can see, the status of the pre-script and post-script is provided.
37
+
When your update deployment is complete, you can go to **Update deployments** to view the results. As you can see, the status is provided for the pre-script and post-script:
@@ -58,18 +58,21 @@ When you configure pre and post-scripts, you can pass in parameters just like sc
58
58
59
59
If you need another object type, you can cast it to another type with your own logic in the runbook.
60
60
61
-
In addition to your standard runbook parameters, another parameter is provided: **SoftwareUpdateConfigurationRunContext**. This parameter is a JSON string, and if you define the parameter in your pre or post-script, it's automatically passed in by the update deployment. The parameter contains information about the update deployment, which is a subset of information returned by the [SoftwareUpdateconfigurations API](/rest/api/automation/softwareupdateconfigurations/getbyname#updateconfiguration) The following table shows you the properties that are provided in the variable.
61
+
In addition to your standard runbook parameters, another parameter is provided: **SoftwareUpdateConfigurationRunContext**
62
62
63
+
This parameter is a JSON string, and if you define the parameter in your pre or post-script, it's automatically passed in by the update deployment. The parameter contains information about the update deployment, which is a subset of information returned by the [SoftwareUpdateconfigurations API](/rest/api/automation/softwareupdateconfigurations/getbyname#updateconfiguration).
64
+
65
+
The following table shows you the properties that are provided in the variable.
|SoftwareUpdateConfigurationName | The name of the software update configuration |
71
+
|SoftwareUpdateConfigurationName | The name of the software update configuration.|
69
72
|SoftwareUpdateConfigurationRunId | The unique ID for the run. |
70
73
|SoftwareUpdateConfigurationSettings | A collection of properties related to the software update configuration. |
71
74
|SoftwareUpdateConfigurationSettings.operatingSystem | The operating systems targeted for the update deployment. |
72
-
|SoftwareUpdateConfigurationSettings.duration | The maximum duration of the update deployment run as `PT[n]H[n]M[n]S` as per ISO8601, also called the *maintenance window*. |
75
+
|SoftwareUpdateConfigurationSettings.duration | The maximum duration of the update deployment run as `PT[n]H[n]M[n]S` as per ISO8601; also called the *maintenance window*. |
73
76
|SoftwareUpdateConfigurationSettings.Windows | A collection of properties related to Windows computers. |
74
77
|SoftwareUpdateConfigurationSettings.Windows.excludedKbNumbers | A list of KBs that are excluded from the update deployment. |
75
78
|SoftwareUpdateConfigurationSettings.Windows.includedUpdateClassifications | Update classifications selected for the update deployment. |
@@ -107,7 +110,7 @@ The following example is a JSON string passed in to the **SoftwareUpdateConfigur
107
110
}
108
111
```
109
112
110
-
A full example with all properties can be found at: [Software update configurations – Get by name](/rest/api/automation/softwareupdateconfigurations/getbyname#examples).
113
+
A full example with all properties can be found at: [Get software update configuration by name](/rest/api/automation/softwareupdateconfigurations/getbyname#examples).
111
114
112
115
> [!NOTE]
113
116
> The `SoftwareUpdateConfigurationRunContext` object can contain duplicate entries for machines. This can cause pre and post-scripts to run multiple times on the same machine. To work around this behavior, use `Sort-Object -Unique` to select only unique VM names in your script.
@@ -132,7 +135,7 @@ foreach($summary in $finalStatus)
132
135
133
136
## Samples
134
137
135
-
Samples for pre and post-scripts can be found in the [Script Center Gallery](https://gallery.technet.microsoft.com/scriptcenter/site/search?f%5B0%5D.Type=RootCategory&f%5B0%5D.Value=WindowsAzure&f%5B0%5D.Text=Windows%20Azure&f%5B1%5D.Type=SubCategory&f%5B1%5D.Value=WindowsAzure_automation&f%5B1%5D.Text=Automation&f%5B2%5D.Type=SearchText&f%5B2%5D.Value=update%20management&f%5B3%5D.Type=Tag&f%5B3%5D.Value=Patching&f%5B3%5D.Text=Patching&f%5B4%5D.Type=ProgrammingLanguage&f%5B4%5D.Value=PowerShell&f%5B4%5D.Text=PowerShell), [PowerShell Gallery](https://www.powershellgallery.com/packages?q=Tags%3A%22UpdateManagement%22+Tags%3A%22Automation%22), or you can import them through the Azure portal. To do that, in your Automation Account, under **Process Automation**, select **Runbooks Gallery**. Use **Update Management** for the filter.
138
+
Samples for pre and post-scripts can be found in the [Script Center Gallery](https://gallery.technet.microsoft.com/scriptcenter/site/search?f%5B0%5D.Type=RootCategory&f%5B0%5D.Value=WindowsAzure&f%5B0%5D.Text=Windows%20Azure&f%5B1%5D.Type=SubCategory&f%5B1%5D.Value=WindowsAzure_automation&f%5B1%5D.Text=Automation&f%5B2%5D.Type=SearchText&f%5B2%5D.Value=update%20management&f%5B3%5D.Type=Tag&f%5B3%5D.Value=Patching&f%5B3%5D.Text=Patching&f%5B4%5D.Type=ProgrammingLanguage&f%5B4%5D.Value=PowerShell&f%5B4%5D.Text=PowerShell) and the [PowerShell Gallery](https://www.powershellgallery.com/packages?q=Tags%3A%22UpdateManagement%22+Tags%3A%22Automation%22), or you can import them through the Azure portal. To do that, in your automation account, under **Process Automation**, select **Runbooks Gallery**. Use **Update Management** for the filter.
@@ -145,7 +148,7 @@ Or you can search for them by their script name, as shown in the following list:
145
148
* Update Management - Run Script with Run Command
146
149
147
150
> [!IMPORTANT]
148
-
> After you import the runbooks, you must **Publish** them before they can be used. To do that, find the runbook in your automation account, select **Edit**, and select **Publish**.
151
+
> After you import the runbooks, you must publish them before they can be used. To do that, find the runbook in your automation account, select **Edit**, and then select **Publish**.
149
152
150
153
The samples are all based on the basic template that's defined in the following example. This template can be used to create your own runbook to use with pre and post-scripts. The necessary logic for authenticating with Azure and handling the `SoftwareUpdateConfigurationRunContext` parameter is included.
Pre and post-script tasks run as a runbook in your automation account and not directly on the machines in your deployment. Pre and post-script tasks also run in the Azure context and don't have access to non-Azure machines. The following sections show how you can interact with the machines directly, whether they're Azure VMs or non-Azure machines.
208
+
Pre and post-tasks run as a runbook in your automation account and not directly on the machines in your deployment. Pre and post-tasks also run in the Azure context and don't have access to non-Azure machines. The following sections show how you can interact with the machines directly, whether they're Azure VMs or non-Azure machines.
206
209
207
210
### Interacting with Azure machines
208
211
@@ -211,18 +214,18 @@ Pre and post-tasks are run as runbooks and don't natively run on your Azure VMs
211
214
* A Run As account
212
215
* A runbook you want to run
213
216
214
-
To interact with Azure machines, you should use the [Invoke-AzureRmVMRunCommand](/powershell/module/azurerm.compute/invoke-azurermvmruncommand) cmdlet to interact with your Azure VMs. For an example of how to do this, see the runbook example [Update Management - Run script with Run command](https://gallery.technet.microsoft.com/Update-Management-Run-40f470dc).
217
+
To interact with Azure machines, you should use the [Invoke-AzureRmVMRunCommand](/powershell/module/azurerm.compute/invoke-azurermvmruncommand) cmdlet to interact with your Azure VMs. For an example of how to do this, see the runbook example [Update Management – run script with Run command](https://gallery.technet.microsoft.com/Update-Management-Run-40f470dc).
215
218
216
219
### Interacting with Non-Azure machines
217
220
218
-
Pre and post-script tasks run in the Azure context and don't have access to non-Azure machines. To interact with the non-Azure machines, you must have the following items:
221
+
Pre and post-tasks run in the Azure context and don't have access to non-Azure machines. To interact with the non-Azure machines, you must have the following items:
219
222
220
223
* A Run As account
221
224
* Hybrid Runbook Worker installed on the machine
222
225
* A runbook you want to run locally
223
226
* A parent runbook
224
227
225
-
To interact with non-Azure machines, a parent runbook is run in the Azure context. This runbook calls a child runbook with the [Start-AzureRmAutomationRunbook](/powershell/module/azurerm.automation/start-azurermautomationrunbook) cmdlet. You must specify the `-RunOn` parameter and provide the name of the Hybrid Runbook Worker for the script to run on. For more info, see the runbook example [Update Management - Run Script Locally](https://gallery.technet.microsoft.com/Update-Management-Run-6949cc44).
228
+
To interact with non-Azure machines, a parent runbook is run in the Azure context. This runbook calls a child runbook with the [Start-AzureRmAutomationRunbook](/powershell/module/azurerm.automation/start-azurermautomationrunbook) cmdlet. You must specify the `-RunOn` parameter and provide the name of the Hybrid Runbook Worker for the script to run on. For more info, see the runbook example [Update Management – run script locally](https://gallery.technet.microsoft.com/Update-Management-Run-6949cc44).
226
229
227
230
## Abort patch deployment
228
231
@@ -238,7 +241,7 @@ if (<My custom error logic>)
238
241
239
242
## Known issues
240
243
241
-
* You can't pass a boolean, objects, or arrays to parameters when you're using pre and post-scripts. If you do, the runbook fails. For a complete list of supported types, see [parameters](#passing-parameters).
244
+
* You can't pass a boolean, objects, or arrays to parameters when you're using pre and post-scripts. If you do, the runbook fails. For a complete list of supported types, see [Passing parameters](#passing-parameters).
0 commit comments