Replace Dism commands with Repair-WindowsImage#325
Conversation
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.
There was a problem hiding this comment.
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
/AnalyzeComponentStorewithRepair-WindowsImage -Online -ScanHealth(different operation). - Replaced two
/StartComponentCleanupcalls withRepair-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 |
There was a problem hiding this comment.
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.
|
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) |
|
Hi @aiburns-msft 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. Mabye my suggestions make more sense at a later time when the module has been updated to be more feature equal to native dism? |
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.