Skip to content

Commit e125cbe

Browse files
committed
edit pass: pre-post-scripts
1 parent 2bb6b0a commit e125cbe

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

articles/automation/pre-post-scripts.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ Select the script you want to use. In this example, we use the **UpdateManagemen
2828

2929
Repeat this process for the **UpdateManagement-TurnOffVms** script. But when you choose the **Script type**, select **Post-Script**.
3030

31-
The **Selected items** section now shows both your scripts selected. One is a pre-script and the other is a post-script.
31+
The **Selected items** section now shows both your scripts selected. One is a pre-script and the other is a post-script:
3232

3333
![Selected items](./media/pre-post-scripts/selected-items.png)
3434

3535
Finish configuring your update deployment.
3636

37-
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:
3838

3939
![Update results](./media/pre-post-scripts/update-results.png)
4040

@@ -58,18 +58,21 @@ When you configure pre and post-scripts, you can pass in parameters just like sc
5858

5959
If you need another object type, you can cast it to another type with your own logic in the runbook.
6060

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**
6262

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.
6366

6467
### SoftwareUpdateConfigurationRunContext properties
6568

6669
|Property |Description |
6770
|---------|---------|
68-
|SoftwareUpdateConfigurationName | The name of the software update configuration |
71+
|SoftwareUpdateConfigurationName | The name of the software update configuration. |
6972
|SoftwareUpdateConfigurationRunId | The unique ID for the run. |
7073
|SoftwareUpdateConfigurationSettings | A collection of properties related to the software update configuration. |
7174
|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*. |
7376
|SoftwareUpdateConfigurationSettings.Windows | A collection of properties related to Windows computers. |
7477
|SoftwareUpdateConfigurationSettings.Windows.excludedKbNumbers | A list of KBs that are excluded from the update deployment. |
7578
|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
107110
   }
108111
```
109112

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).
111114

112115
> [!NOTE]
113116
> 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)
132135

133136
## Samples
134137

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.
136139

137140
![Gallery list](./media/pre-post-scripts/runbook-gallery.png)
138141

@@ -145,7 +148,7 @@ Or you can search for them by their script name, as shown in the following list:
145148
* Update Management - Run Script with Run Command
146149

147150
> [!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**.
149152
150153
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.
151154

@@ -202,7 +205,7 @@ $variable = Get-AutomationVariable -Name $runId
202205

203206
## Interacting with machines
204207

205-
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.
206209

207210
### Interacting with Azure machines
208211

@@ -211,18 +214,18 @@ Pre and post-tasks are run as runbooks and don't natively run on your Azure VMs
211214
* A Run As account
212215
* A runbook you want to run
213216

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).
215218

216219
### Interacting with Non-Azure machines
217220

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:
219222

220223
* A Run As account
221224
* Hybrid Runbook Worker installed on the machine
222225
* A runbook you want to run locally
223226
* A parent runbook
224227

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).
226229

227230
## Abort patch deployment
228231

@@ -238,7 +241,7 @@ if (<My custom error logic>)
238241

239242
## Known issues
240243

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).
242245

243246
## Next steps
244247

0 commit comments

Comments
 (0)