Simon Vedder

Cloud Engineer · Zürich

Invoke-InPlaceUpgrade

Start an in-place upgrade and wait for it to finish, in one call

Start-InPlaceUpgrade, then Complete-InPlaceUpgrade every -PollIntervalSeconds until the VM reaches Completed or Failed or -TimeoutMinutes pass. That is the only difference from calling the two yourself: this one blocks for the whole upgrade, 30 to 120 minutes.

Do not use it inside Azure Automation. A cloud job is cancelled after three hours, which is less than a slow upgrade needs - that is why the runbook calls Start and Complete separately. For a console, Cloud Shell or a Hybrid Runbook Worker, this is the shorter path. For local runs, Cloud Shell and Hybrid Runbook Workers. Do not use it in an Azure Automation cloud job: those are cancelled after three hours (ADR 0003); schedule Start and Complete separately there.

Syntax

Invoke-InPlaceUpgrade -VM <Object> -Target <string> [-Engine <string>] [-MediaDiskResourceGroupName <string>] [-MediaDiskSkuName <string>] [-ProductKey <string>] [-UseMatrixProductKey] [-TargetImageIndex <int>] [-MinimumFreeSpaceGB <int>] [-Force] [-KeepMediaDisk] [-TimeoutMinutes <int>] [-PollIntervalSeconds <int>] [-LogIngestionEndpoint <string>] [-DataCollectionRuleId <string>] [-WhatIf] [-Confirm] [<CommonParameters>]

Invoke-InPlaceUpgrade -ResourceGroupName <string> -Name <string> -Target <string> [-Engine <string>] [-MediaDiskResourceGroupName <string>] [-MediaDiskSkuName <string>] [-ProductKey <string>] [-UseMatrixProductKey] [-TargetImageIndex <int>] [-MinimumFreeSpaceGB <int>] [-Force] [-KeepMediaDisk] [-TimeoutMinutes <int>] [-PollIntervalSeconds <int>] [-LogIngestionEndpoint <string>] [-DataCollectionRuleId <string>] [-WhatIf] [-Confirm] [<CommonParameters>]

Requirements

PermissionsThe union of Start-InPlaceUpgrade and Complete-InPlaceUpgrade
PrerequisitesPowerShell 7.2+, Az.Compute, Az.Resources; an established Azure context; a session that may run for hours

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.
-TargetStringyesnoRequired. Target key from the matrix, for example WS2025; Get-InPlaceUpgradeTarget lists them. The module never reads it from a tag - the caller states the target.
-EngineStringnonoMediaDiskMediaDisk (default) or FeatureUpdate (experimental, WS2019/WS2022 only); see Start-InPlaceUpgrade.
-MediaDiskResourceGroupNameStringnonoResource group for the media disk. Defaults to the VM’s resource group.
-MediaDiskSkuNameStringnonoStandard_LRSStorage SKU of the media disk.
-ProductKeyStringnonoExplicit public KMS client setup key for setup.exe /pkey.
-UseMatrixProductKeySwitchParameternonoPass the matrix’s public KMS client setup key for the guest’s edition as /pkey.
-TargetImageIndexInt32nono0install.wim image index for setup.exe /installfrom and /imageindex.
-MinimumFreeSpaceGBInt32nono30Free space required on C: by the preflight.
-ForceSwitchParameternonoProceed although the preflight reports NotEligible, and suppress the confirmation prompt.
-KeepMediaDiskSwitchParameternonoKeep the media disk after the final state.
-TimeoutMinutesInt32nono240How long to wait for the upgrade before declaring it Failed.
-PollIntervalSecondsInt32nono120Seconds between two guest checks.
-LogIngestionEndpointStringnonoLogs ingestion endpoint for telemetry; see Start-InPlaceUpgrade.
-DataCollectionRuleIdStringnonoImmutable id of the data collection rule; see Start-InPlaceUpgrade.

Supports -WhatIf and -Confirm.

Examples

Example 1

# End to end on one lab VM, five-hour budget, checking every two minutes
Invoke-InPlaceUpgrade -ResourceGroupName rg-ipu-lab-weu -Name vm-ipu-2022-01 -Target WS2025 -TimeoutMinutes 300 -Confirm:$false -Verbose

Output

  • AzureInPlaceUpgrade.StartResult when Start did not start anything, otherwise AzureInPlaceUpgrade.CompleteResult

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