Skip to content

Replace Dism commands with Repair-WindowsImage#325

Open
Karl-WE wants to merge 1 commit into
Azure:mainfrom
Karl-WE:patch-1
Open

Replace Dism commands with Repair-WindowsImage#325
Karl-WE wants to merge 1 commit into
Azure:mainfrom
Karl-WE:patch-1

Conversation

@Karl-WE

@Karl-WE Karl-WE commented Jul 7, 2026

Copy link
Copy Markdown

Replacing all cmdline dism commands with PowerShell dism module, which comes integrated into the OS works with PS5.1 and 7.x likewise.

Staying in PowerShell syntax is cleaner and more efficient as there as less characters to type and it offers autocompletion. Output / Progress / eventually piping.

Replacing all cmdline dism commands with PowerShell dism module, which comes integrated into the OS works with PS5.1 and 7.x likewise. 

Staying in PowerShell syntax is cleaner and more efficient as there as less characters to type and it offers autocompletion.
Output / Progress / eventually piping.
Copilot AI review requested due to automatic review settings July 7, 2026 19:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR replaces command-line Dism.exe invocations with the DISM PowerShell module's Repair-WindowsImage cmdlet in the "System Drive Free Space" troubleshooting guide, with the stated goal of staying in PowerShell syntax that works on both PS 5.1 and 7.x. While the intent (a consistent PowerShell experience) is reasonable, the specific cmdlet parameters chosen do not map to the original DISM operations, which breaks the documented commands.

Changes:

  • Replaced /AnalyzeComponentStore with Repair-WindowsImage -Online -ScanHealth (different operation).
  • Replaced two /StartComponentCleanup calls with Repair-WindowsImage -Online -StartComponentCleanup (unsupported parameter).
  • Left the surrounding exit-code reporting logic ($LASTEXITCODE) unchanged, which no longer applies to cmdlet output.


# How much the Windows component store (WinSxS) can reclaim
Dism.exe /Online /Cleanup-Image /AnalyzeComponentStore
Repair-WindowsImage -Online -ScanHealth

@Karl-WE Karl-WE Jul 7, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am a bit baffled that this is the second command, found missing in dism module now. The other one is a specific compression methods for exporting images (Export-WindowsImage). 🤔

Asking internally on DL.

@AlBurns-MSFT

AlBurns-MSFT commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator

I decided to give this a review @Karl-WE hope it helps.

Review results — PR #325 (Azure/AzureLocal-Supportability): "Replace Dism commands with Repair-WindowsImage"

Verdict: DEFECTS — 2 BUGs (both LOW RISK). Two of the three  Dism  →  Repair-WindowsImage  swaps change behavior; the third is faithful. Both defects proven on lab hardware and against the cmdlet docs.

BUG 1 — line 187, "Find what is using the system drive."  Dism /Online /Cleanup-Image /AnalyzeComponentStore  →  Repair-WindowsImage -Online -ScanHealth  is not equivalent.  AnalyzeComponentStore  reports reclaimable space;  -ScanHealth  is a corruption scan (the cmdlet has no  -AnalyzeComponentStore ). Lab: ScanHealth returned only  ImageHealthState : Healthy ; AnalyzeComponentStore returned  Reclaimable Packages : 6, Cleanup Recommended : Yes . The unchanged comment ("how much WinSxS can reclaim") and the downstream Tier-1a prose ("if the analysis still reports reclaimable packages") are now orphaned. Fix: keep the DISM form here (read-only, no cmdlet equivalent), or reword the comment + prose to component-store health.

BUG 2 — lines 286–287, "Run Tier 1 across all nodes." Native  Dism.exe  swapped for the cmdlet, but  ExitCode = $LASTEXITCODE  and the comment "0 = succeeded" stayed. Cmdlets don't set  $LASTEXITCODE  (lab:  $null /stale after the cmdlet; only native DISM set  0 );  Repair-WindowsImage  throws on failure instead. Result: success rows show blank, a failing node's row can drop — masking partial fleet failure. Fix:  try/catch  with  -ErrorAction Stop , emit an explicit  Status  (+  RestartNeeded ), point the comment at  Status .

Not a defect — line 241. Standalone  Repair-WindowsImage -Online -StartComponentCleanup  is a faithful swap (param exists, same engine, no  /ResetBase  dropped). Lint: no PR-attributable defect (the line 317 ERROR is a harness placeholder on an unchanged block outside the diff).

Lab evidence: Azure Local 24H2 (build 26100, DISM module v3.0)

@Karl-WE

Karl-WE commented Jul 18, 2026

Copy link
Copy Markdown
Author

Hi @aiburns-msft
Thank you very much for your time.

I believe it is feasible to get in touch with servicing team. Can you connect me via MVP channels / teams or DL.

It seems that dism module has a number of limitations given your review and I know about more of these.
Remote related to dism also PS team requires updates on the module as they shifting from msi to msix which dism module doesn't support.

Mabye my suggestions make more sense at a later time when the module has been updated to be more feature equal to native dism?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants