PowerShell DISM: Manage Windows Images and Features

Not every Windows machine has the Server Manager role-management cmdlets, but every Windows installation includes DISM — the Deployment Image Servicing and Management tool. Running PowerShell DISM Windows features commands lets you enable and disable optional components, repair corrupted system files, and service offline WIM images on both desktop and server SKUs without any additional modules.
Quick Answer / TL;DR
Use dism /online /Enable-Feature /FeatureName:FeatureName to enable a Windows feature from PowerShell. Use Repair-WindowsImage -Online -RestoreHealth (via the DISM PowerShell module) for Windows repair.
List Windows Optional Features
There are two ways to list features: the legacy dism.exe command-line tool and the Get-WindowsOptionalFeature PowerShell cmdlet from the built-in DISM module. The PowerShell cmdlet returns proper objects you can filter and sort.
# PowerShell cmdlet — returns objects (preferred)
Get-WindowsOptionalFeature -Online | Sort-Object FeatureName |
Format-Table FeatureName, State -AutoSize
# Filter to enabled features only
Get-WindowsOptionalFeature -Online |
Where-Object State -eq 'Enabled' |
Select-Object FeatureName
# Legacy dism.exe — same information as text
dism /Online /Get-Features /Format:Table
Enable and Disable Features
Use Enable-WindowsOptionalFeature and Disable-WindowsOptionalFeature to change feature state. Add -NoRestart to suppress automatic reboots in scripts that handle restarts separately. Some features require a restart to complete — check the RestartNeeded property of the returned object.
# Enable a feature (run as Administrator)
$result = Enable-WindowsOptionalFeature -Online -FeatureName 'TelnetClient' -NoRestart
if ($result.RestartNeeded) {
Write-Warning "Restart required to complete feature installation"
}
# Enable multiple features
'TFTP', 'TelnetClient' | ForEach-Object {
Enable-WindowsOptionalFeature -Online -FeatureName $_ -NoRestart | Out-Null
Write-Host "Enabled: $_"
}
# Disable a feature
Disable-WindowsOptionalFeature -Online -FeatureName 'TelnetClient' -NoRestart
Repair Windows Image with RestoreHealth
Repair-WindowsImage -Online -RestoreHealth runs DISM’s component store repair using Windows Update as the source. It scans for corruption and replaces damaged files automatically. This requires internet access unless you provide a local source with -Source. Run as Administrator.
# Full repair — scans and fixes corruption (requires internet)
Repair-WindowsImage -Online -RestoreHealth
# Check health first — faster than full repair
$health = Get-WindowsImage -ImagePath (Get-WindowsImage -Online).ImagePath -ErrorAction SilentlyContinue
Repair-WindowsImage -Online -CheckHealth
# Repair using offline source (no internet required)
Repair-WindowsImage -Online -RestoreHealth -Source 'D:\Sources\SxS' -LimitAccess
Service an Offline WIM Image
DISM can add features, drivers, and updates to a Windows image file (WIM/ESD) without booting it. Mount the image to a folder, make changes, then commit and unmount. This is the standard workflow for customizing OS deployment images.
# Mount the WIM image to a staging folder
$mountPath = 'C:\WIMMount'
New-Item -Path $mountPath -ItemType Directory -Force | Out-Null
Mount-WindowsImage -ImagePath 'C:\Images\install.wim' -Index 1 -Path $mountPath
# Add a feature to the offline image
Enable-WindowsOptionalFeature -Path $mountPath -FeatureName 'TelnetClient'
# Add a driver package
Add-WindowsDriver -Path $mountPath -Driver 'C:\Drivers\network' -Recurse
# Commit changes and unmount
Dismount-WindowsImage -Path $mountPath -Save
Write-Host 'Image servicing complete'
DISM vs Install-WindowsFeature
Install-WindowsFeature (from the ServerManager module) only exists on Windows Server. DISM works on both Windows client and server. Use Install-WindowsFeature on servers for role management (IIS, Hyper-V, AD DS), and DISM when the script must work on both Windows 10/11 and Server, or when managing optional features rather than server roles.
# Detect which tool to use
if (Get-Command Install-WindowsFeature -ErrorAction SilentlyContinue) {
# Windows Server with ServerManager module
Install-WindowsFeature -Name 'Web-Server' -IncludeManagementTools
} else {
# Windows Desktop — use DISM
Enable-WindowsOptionalFeature -Online -FeatureName 'IIS-WebServer' -NoRestart
}
Save DISM Log Output
DISM automatically logs to %windir%\Logs\DISM\dism.log. For scripts, capture PowerShell cmdlet output and save it alongside the DISM log for audit trails. The dism.exe command accepts /LogPath to redirect its native log.
# Run DISM repair and capture output
$logPath = "C:\Logs\DismRepair_$(Get-Date -Format 'yyyyMMdd').log"
$result = Repair-WindowsImage -Online -RestoreHealth 4>&1
$result | Out-File $logPath
Write-Host "DISM repair complete. Log: $logPath"
# Check Windows DISM log
$dismLog = "$env:windir\Logs\DISM\dism.log"
if (Test-Path $dismLog) {
Get-Content $dismLog | Select-Object -Last 20
}
Common Errors and Fixes
- DISM repair requires internet or a mounted install source.
Repair-WindowsImage -RestoreHealthdownloads replacement files from Windows Update. Behind a proxy, add proxy settings to WinHTTP:netsh winhttp set proxy proxy.corp.com:8080. Without internet, use-Source 'D:\Sources\SxS' -LimitAccesspointing to an installation media source. - Running DISM inside PowerShell requires correct path quoting. Paths with spaces must be quoted when calling
dism.exedirectly. Use PowerShell cmdlets (Enable-WindowsOptionalFeature,Repair-WindowsImage) whenever possible to avoid quoting issues and get proper object output.
Related Cmdlets / See Also
Wrapping Up
DISM is the universal Windows image tool that works on every Windows SKU. Use the PowerShell DISM module cmdlets (Get-WindowsOptionalFeature, Enable-WindowsOptionalFeature, Repair-WindowsImage) for scripting rather than dism.exe directly. For role management on Windows Server, Install-WindowsFeature provides a higher-level interface.


