Simon Vedder

Cloud Engineer · Zürich

Complete-InPlaceUpgrade

Check a VM whose upgrade was started and report Completed, InProgress or Failed

The Check half of the state machine (ADR 0003). One look at the guest, one answer - it does not loop and it does not wait. Call it on a schedule, or let Invoke-InPlaceUpgrade call it for you until the machine is done. Reads the build number, Setup processes and the scheduled task result from the guest and decides: Completed when the guest reports the target build, InProgress while Setup runs or the guest is rebooting, Failed when the task ended with an error, the VM was stopped, or -StartedAt is older than -TimeoutMinutes. On a final state the media disk is detached and deleted and the scheduled task removed; the snapshot is kept as the rollback point. It evaluates whichever VM it is given - the caller decides which ones are in flight. Safe to run every few minutes.

Syntax

Complete-InPlaceUpgrade -VM <Object> -Target <string> [-Snapshot <string>] [-MediaDisk <string>] [-Engine <string>] [-StartedAt <datetime>] [-TimeoutMinutes <int>] [-KeepMediaDisk] [-LogIngestionEndpoint <string>] [-DataCollectionRuleId <string>] [-WhatIf] [-Confirm] [<CommonParameters>]

Complete-InPlaceUpgrade -ResourceGroupName <string> -Name <string> -Target <string> [-Snapshot <string>] [-MediaDisk <string>] [-Engine <string>] [-StartedAt <datetime>] [-TimeoutMinutes <int>] [-KeepMediaDisk] [-LogIngestionEndpoint <string>] [-DataCollectionRuleId <string>] [-WhatIf] [-Confirm] [<CommonParameters>]

Requirements

PermissionsMicrosoft.Compute/virtualMachines/read, write, instanceView/read, runCommand/action; Microsoft.Compute/disks/read, delete
PrerequisitesPowerShell 7.2+, Az.Compute, Az.Resources; an established Azure context

Parameters

NameTypeRequiredPipelineDefaultDescription
-VMObjectyesyesThe VM object from Get-AzVM. Accepts pipeline input.
-ResourceGroupNameStringyesnoResource group of the VM when -Name is used instead of -VM.
-NameStringyesnoName of the VM when -ResourceGroupName is used instead of -VM.
-TargetStringyesnoWhat Start left behind. Pass the values, or splat the whole StartResult with -StartResult.
-SnapshotStringnonoName of the OS disk snapshot Start-InPlaceUpgrade took before the upgrade. Carried into the telemetry record and into the result so a rollback target is never guessed. Comes from the StartResult; pass it yourself only when you are completing a run you started by other means.
-MediaDiskStringnonoName of the managed disk holding the upgrade media that Start attached. Used to detach and delete it once the upgrade succeeded, unless -KeepMediaDisk is set. Also from the StartResult.
-EngineStringnonoMediaDiskWhich engine Start used: MediaDisk (Microsoft’s upgrade media as a managed disk, the proven path) or FeatureUpdate (Windows Update). It decides how the completion is judged and what cleanup is needed. Defaults to MediaDisk.
-StartedAtDateTimenonoWhen the upgrade was started, as recorded by Start-InPlaceUpgrade. -TimeoutMinutes is measured from it. Without it the timeout cannot be applied and the command warns and keeps waiting, so pass it for any unattended run.
-TimeoutMinutesInt32nono240How old -StartedAt may be before a VM that has not reached the target build is declared Failed.
-KeepMediaDiskSwitchParameternonoKeep the media disk after a final state. Costs money; useful when debugging.
-LogIngestionEndpointStringnonoLogs ingestion endpoint of a data collection endpoint. With -DataCollectionRuleId, every evaluation (InProgress, Completed, Failed) is written to the InPlaceUpgrade_CL table.
-DataCollectionRuleIdStringnonoImmutable id (dcr-…) of the data collection rule that routes Custom-InPlaceUpgrade_CL.

Supports -WhatIf and -Confirm.

Examples

Example 1

# Check one VM whose upgrade is in flight
Complete-InPlaceUpgrade -ResourceGroupName rg-apps-prod-weu -Name vm-app-prod-weu-01 -Target WS2025 |
    Select-Object VMName, Result, Reason

Example 2

# One VM, keep the media disk for inspection
Complete-InPlaceUpgrade -ResourceGroupName rg-apps-prod-weu -Name vm-app-prod-weu-01 -KeepMediaDisk

Output

  • AzureInPlaceUpgrade.CompleteResult

Generated from the comment-based help in the module. Same text as Get-Help Complete-InPlaceUpgrade -Full, and as the copy on GitHub.