Skip to content

Commit 8f9e589

Browse files
authored
Updated returns
Added return data for check and apply pending update cmds
1 parent 2f6fd7e commit 8f9e589

File tree

1 file changed

+30
-5
lines changed

1 file changed

+30
-5
lines changed

articles/virtual-machines/maintenance-control-powershell.md

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.service: virtual-machines
88
ms.topic: article
99
ms.tgt_pltfrm: vm
1010
ms.workload: infrastructure-services
11-
ms.date: 12/06/2019
11+
ms.date: 01/31/2020
1212
ms.author: cynthn
1313
---
1414

@@ -34,7 +34,7 @@ With maintenance control, you can:
3434

3535
- VMs must be on a [dedicated host](./linux/dedicated-hosts.md), or be created using an [isolated VM size](./linux/isolation.md).
3636
- After 35 days, an update will automatically be applied.
37-
- User must have **Resource Owner** access.
37+
- User must have **Resource Contributor** access.
3838

3939

4040
## Enable the PowerShell module
@@ -128,7 +128,19 @@ New-AzConfigurationAssignment `
128128

129129
Use [Get-AzMaintenanceUpdate](https://docs.microsoft.com/powershell/module/az.maintenance/get-azmaintenanceupdate) to see if there are pending updates. Use `-subscription` to specify the Azure subscription of the VM if it is different from the one that you are logged into.
130130

131-
If there are no updates, the command will return an error message: `Resource not found...StatusCode: 404`.
131+
If there are no updates to show, this command will return nothing. Otherwise, it will return a PSApplyUpdate object:
132+
133+
```json
134+
{
135+
"maintenanceScope": "Host",
136+
"impactType": "Freeze",
137+
"status": "Pending",
138+
"impactDurationInSec": 9,
139+
"notBefore": "2020-02-21T16:47:44.8728029Z",
140+
"properties": {
141+
"resourceId": "/subscriptions/39c6cced-4d6c-4dd5-af86-57499cd3f846/resourcegroups/Ignite2019/providers/Microsoft.Compute/virtualMachines/MCDemo3"
142+
}
143+
```
132144

133145
### Isolated VM
134146

@@ -142,6 +154,7 @@ Get-AzMaintenanceUpdate `
142154
-ProviderName Microsoft.Compute | Format-Table
143155
```
144156

157+
145158
### Dedicated host
146159

147160
To check for pending updates for a dedicated host. In this example, the output is formatted as a table for readability. Replace the values for the resources with your own.
@@ -156,6 +169,7 @@ Get-AzMaintenanceUpdate `
156169
-ProviderName Microsoft.Compute | Format-Table
157170
```
158171

172+
159173
## Apply updates
160174

161175
Use [New-AzApplyUpdate](https://docs.microsoft.com/powershell/module/az.maintenance/new-azapplyupdate) to apply pending updates.
@@ -172,6 +186,8 @@ New-AzApplyUpdate `
172186
-ProviderName Microsoft.Compute
173187
```
174188

189+
On success, this command will return a `PSApplyUpdate` object. You can use the Name attribute in the `Get-AzApplyUpdate` command to check the update status. See [Check update status](#check-update-status).
190+
175191
### Dedicated host
176192

177193
Apply updates to a dedicated host.
@@ -189,7 +205,16 @@ New-AzApplyUpdate `
189205
## Check update status
190206
Use [Get-AzApplyUpdate](https://docs.microsoft.com/powershell/module/az.maintenance/get-azapplyupdate) to check on the status of an update. The commands shown below show the status of the latest update by using `default` for the `-ApplyUpdateName` parameter. You can substitute the name of the update (returned by the [New-AzApplyUpdate](https://docs.microsoft.com/powershell/module/az.maintenance/new-azapplyupdate) command) to get the status of a specific update.
191207

192-
If there are no updates to show, the command will return an error message: `Resource not found...StatusCode: 404`.
208+
```text
209+
Status : Completed
210+
ResourceId : /subscriptions/12ae7457-4a34-465c-94c1-17c058c2bd25/resourcegroups/TestShantS/providers/Microsoft.Comp
211+
ute/virtualMachines/DXT-test-04-iso
212+
LastUpdateTime : 1/1/2020 12:00:00 AM
213+
Id : /subscriptions/12ae7457-4a34-465c-94c1-17c058c2bd25/resourcegroups/TestShantS/providers/Microsoft.Comp
214+
ute/virtualMachines/DXT-test-04-iso/providers/Microsoft.Maintenance/applyUpdates/default
215+
Name : default
216+
Type : Microsoft.Maintenance/applyUpdates
217+
```
193218

194219
### Isolated VM
195220

@@ -216,7 +241,7 @@ Get-AzApplyUpdate `
216241
-ResourceParentName myHostGroup `
217242
-ResourceParentType hostGroups `
218243
-ProviderName Microsoft.Compute `
219-
-ApplyUpdateName default
244+
-ApplyUpdateName myUpdateName
220245
```
221246

222247
## Remove a maintenance configuration

0 commit comments

Comments
 (0)