Managing Windows Features and Images with DISM and PowerShell
Overview
Section titled “Overview”This article treats DISM (Deployment Image Servicing and Management) and PowerShell (the DISM API wrapper) side by side. It organizes frequent admin tasks with concise explanations, key options, and ready-to-run examples.
Variable Conventions
Section titled “Variable Conventions”| Variable | Example | Notes |
|---|---|---|
<<IMAGE_PATH>> | C:\mount or E:\Windows | Path for /Image: (mounted offline Windows or another disk’s Windows directory) |
<<FEATURE_NAME>> | NetFx3 | Windows feature name |
<<CAPABILITY_NAME>> | OpenSSH.Client~~~~0.0.1.0 | Feature on Demand name (FoD) |
<<WIM_PATH>> | D:\sources\install.wim | WIM/ESD image file |
<<INDEX>> | 1 | Image index |
<<MOUNT_DIR>> | C:\mount | Mount point |
<<DRIVER_DIR>> | D:\drivers | Folder containing driver INF files |
<<PACKAGE_PATH>> | C:\Updates\kb5005565.cab | Update package file |
<<LANG_PACK>> | C:\LP\ja-jp\lp.cab | Language pack CAB |
<<SOURCE_PATH>> | D:\sources\sxs | Source files (e.g., NetFx3) |
<<APPLY_DIR>> | C:\ | Apply/extract destination |
<<SCRATCH_DIR>> | C:\Temp\Scratch | Working directory |
<<LOG_PATH>> | C:\Temp\dism.log | Log path |
Most commands also accept
/ScratchDir:<<SCRATCH_DIR>>and/LogPath:<<LOG_PATH>>.
Step 1: Target Selection (/Online vs /Image)
Section titled “Step 1: Target Selection (/Online vs /Image)”Most DISM commands require an explicit target.
| Option | Meaning | Example |
|---|---|---|
/Online | Current running Windows | dism /Online /Cleanup-Image /CheckHealth |
/Image:<<IMAGE_PATH>> | Offline Windows or mounted image | dism /Image:C:\mount /Add-Driver /Driver:D:\drivers /Recurse |
Step 2: List Features (/Get-Features, /Get-FeatureInfo)
Section titled “Step 2: List Features (/Get-Features, /Get-FeatureInfo)”Summary
Section titled “Summary”Enumerate available features and their state: Enabled / Disabled / DisabledWithPayloadRemoved.
Key Options
Section titled “Key Options”| Option | Meaning | Example |
|---|---|---|
/Online | Target running OS | dism /Online /Get-Features |
/Image:<<IMAGE_PATH>> | Target offline image | dism /Image:C:\mount /Get-Features |
/Get-Features | List features | dism /Online /Get-Features /Format:Table |
/Get-FeatureInfo | Detail for one feature | dism /Online /Get-FeatureInfo /FeatureName:NetFx3 |
/FeatureName:<<FEATURE_NAME>> | Feature name | NetFx3 |
/Format:Table | Tabular output | dism /Online /Get-Features /Format:Table |
Examples
Section titled “Examples”# List all features and statesdism /Online /Get-Features /Format:Table
# Inspect a specific featuredism /Online /Get-FeatureInfo /FeatureName:NetFx3If state is
DisabledWithPayloadRemoved, binaries are removed; specify/Source.
Step 3: Enable/Disable Features (/Enable-Feature, /Disable-Feature)
Section titled “Step 3: Enable/Disable Features (/Enable-Feature, /Disable-Feature)”Summary
Section titled “Summary”Enable/disable features such as .NET Framework 3.5 or SMB 1.0.
Key Options
Section titled “Key Options”| Option | Meaning | Example |
|---|---|---|
/Online | Target running OS | dism /Online /Enable-Feature /FeatureName:NetFx3 |
/FeatureName:<<FEATURE_NAME>> | Feature to manage | NetFx3 |
/All | Include dependencies | |
/Source:<<SOURCE_PATH>> | Payload source when removed | dism /Online /Enable-Feature /FeatureName:NetFx3 /Source:D:\sources\sxs |
/LimitAccess | Don’t use WU/WSUS | |
/Enable-Feature | Enable | dism /Online /Enable-Feature /FeatureName:SMB1Protocol |
/Disable-Feature | Disable | dism /Online /Disable-Feature /FeatureName:SMB1Protocol |
/LogPath:<<LOG_PATH>> | Log output |
Examples
Section titled “Examples”# Enable .NET Framework 3.5 from local media without Internetdism /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:<<SOURCE_PATH>> /LogPath:<<LOG_PATH>>
# Disable SMB1 for hardeningdism /Online /Disable-Feature /FeatureName:SMB1Protocol /LogPath:<<LOG_PATH>>Step 4: Inspect Capabilities (/Get-Capabilities, /Get-CapabilityInfo)
Section titled “Step 4: Inspect Capabilities (/Get-Capabilities, /Get-CapabilityInfo)”Summary
Section titled “Summary”List and inspect FoD (Features on Demand) such as RSAT, OpenSSH.Client, Language.Basic.
Key Options
Section titled “Key Options”| Option | Meaning | Example |
|---|---|---|
/Online | Running OS | dism /Online /Get-Capabilities |
/Image:<<IMAGE_PATH>> | Offline image | dism /Image:C:\mount /Get-Capabilities |
/Get-Capabilities | List FoD | dism /Online /Get-Capabilities /Format:Table |
/Get-CapabilityInfo | Detail | dism /Online /Get-CapabilityInfo /CapabilityName:OpenSSH.Client~~~~0.0.1.0 |
/Format:Table | Tabular output | dism /Online /Get-Capabilities /Format:Table |
Examples
Section titled “Examples”# Enumerate FoDdism /Online /Get-Capabilities /Format:Table
# Inspect one capabilitydism /Online /Get-CapabilityInfo /CapabilityName:<<CAPABILITY_NAME>>Capabilities can be sourced from Windows Update, WSUS, or FoD ISO/shares.
Step 5: Add/Remove Capabilities (/Add-Capability, /Remove-Capability)
Section titled “Step 5: Add/Remove Capabilities (/Add-Capability, /Remove-Capability)”Summary
Section titled “Summary”Add/remove on-demand components like OpenSSH or RSAT tools.
Key Options
Section titled “Key Options”| Option | Meaning | Example |
|---|---|---|
/Online | Running OS | dism /Online /Add-Capability |
/CapabilityName:<<CAPABILITY_NAME>> | Capability to manage | OpenSSH.Client~~~~0.0.1.0 |
/Source:<<SOURCE_PATH>> | FoD ISO or share | dism /Online /Add-Capability /CapabilityName:OpenSSH.Client~~~~0.0.1.0 /Source:D:\ /LimitAccess |
/LimitAccess | Use only given source | |
/LogPath:<<LOG_PATH>> | Log output |
Examples
Section titled “Examples”# Add OpenSSH.Client (online, from network or ISO)dism /Online /Add-Capability /CapabilityName:<<CAPABILITY_NAME>> /LogPath:<<LOG_PATH>>
# Remove an unneeded RSAT tooldism /Online /Remove-Capability /CapabilityName:<<CAPABILITY_NAME>> /LogPath:<<LOG_PATH>>Step 6: Image Repair & Component Store (/Cleanup-Image)
Section titled “Step 6: Image Repair & Component Store (/Cleanup-Image)”Summary
Section titled “Summary”Detect/repair WinSxS corruption and optimize disk usage.
Key Options
Section titled “Key Options”| Option | Meaning | Example |
|---|---|---|
/Online | Running OS | dism /Online /Cleanup-Image /CheckHealth |
/CheckHealth | Quick check | |
/ScanHealth | Deep scan | |
/RestoreHealth | Repair | dism /Online /Cleanup-Image /RestoreHealth |
/Source:<<SOURCE_PATH>> | Repair source | |
/LimitAccess | Avoid WU | |
/StartComponentCleanup | Remove superseded updates | |
/ResetBase | Consolidate (no rollback) | |
/AnalyzeComponentStore | Size analysis |
Examples
Section titled “Examples”# Quick corruption checkdism /Online /Cleanup-Image /CheckHealth
# Deep scandism /Online /Cleanup-Image /ScanHealth
# Repair with local sourcedism /Online /Cleanup-Image /RestoreHealth /Source:<<SOURCE_PATH>> /LimitAccess /LogPath:<<LOG_PATH>>
# Cleanup and consolidate updatesdism /Online /Cleanup-Image /StartComponentCleanup /ResetBase /LogPath:<<LOG_PATH>>Step 7: Image Info (/Get-ImageInfo)
Section titled “Step 7: Image Info (/Get-ImageInfo)”Key Options
Section titled “Key Options”| Option | Meaning | Example |
|---|---|---|
/Get-ImageInfo | Show images inside WIM/ESD | dism /Get-ImageInfo /ImageFile:install.wim |
/ImageFile:<<WIM_PATH>> | WIM to inspect | |
/Index:<<INDEX>> | Target index | |
/LogPath:<<LOG_PATH>> | Log output |
Example
Section titled “Example”# Show editions and indexes in install.wimdism /Get-ImageInfo /ImageFile:<<WIM_PATH>> /LogPath:<<LOG_PATH>>Step 8: Mount & Unmount Offline Images
Section titled “Step 8: Mount & Unmount Offline Images”Key Options
Section titled “Key Options”| Option | Meaning | Example |
|---|---|---|
/Mount-Wim | Mount WIM | |
/WimFile:<<WIM_PATH>> | Source WIM | |
/Index:<<INDEX>> | Index to mount | |
/MountDir:<<MOUNT_DIR>> | Mount directory | |
/ReadOnly | Read-only mount | |
/Get-MountedWimInfo | Show mount status | |
/Unmount-Wim | Unmount | |
/Commit | Save changes | |
/Discard | Discard changes |
Examples
Section titled “Examples”# Mount for editingdism /Mount-Wim /WimFile:<<WIM_PATH>> /Index:<<INDEX>> /MountDir:<<MOUNT_DIR>>
# Check current mountsdism /Get-MountedWimInfo
# Save and unmountdism /Unmount-Wim /MountDir:<<MOUNT_DIR>> /CommitStep 9: Integrate Drivers, Packages, and Language Packs
Section titled “Step 9: Integrate Drivers, Packages, and Language Packs”Key Options
Section titled “Key Options”| Option | Meaning | Example |
|---|---|---|
/Online | Running OS | |
/Image:<<MOUNT_DIR>> | Offline image target | |
/Add-Driver | Add drivers | |
/Driver:<<DRIVER_DIR>> | Folder containing INF | |
/Recurse | Include subfolders | |
/Add-Package | Add updates or language packs | |
/PackagePath:<<PACKAGE_PATH>> | Package path | |
/Set-AllIntl:ja-JP | Set locale to Japanese |
Notes:
/Add-Driveris offline only./Add-Packageand/Set-AllIntlwork online or offline.
Examples
Section titled “Examples”# Integrate driversdism /Image:<<MOUNT_DIR>> /Add-Driver /Driver:<<DRIVER_DIR>> /Recurse
# Integrate an updatedism /Image:<<MOUNT_DIR>> /Add-Package /PackagePath:<<PACKAGE_PATH>>
# Add a language pack and set localedism /Image:<<MOUNT_DIR>> /Add-Package /PackagePath:<<LANG_PACK>>dism /Image:<<MOUNT_DIR>> /Set-AllIntl:ja-JPStep 10: Capture, Export, and Apply Images
Section titled “Step 10: Capture, Export, and Apply Images”Key Options
Section titled “Key Options”| Option | Meaning | Example |
|---|---|---|
/Capture-Image | Capture a folder to WIM | |
/ImageFile:<<WIM_PATH>> | Output WIM | |
/CaptureDir:<<APPLY_DIR>> | Source directory | |
/Name:"<name>" | Image name | |
/Export-Image | Export/compress existing WIM | |
/Apply-Image | Apply WIM | |
/Compress:max | Max compression | |
/ApplyDir:<<APPLY_DIR>> | Destination directory |
Examples
Section titled “Examples”# Capture current layout to WIMdism /Capture-Image /ImageFile:D:\Custom.wim /CaptureDir:<<APPLY_DIR>> /Name:"Custom Image"
# Export with maximum compressiondism /Export-Image /SourceImageFile:<<WIM_PATH>> /SourceIndex:<<INDEX>> /DestinationImageFile:D:\install_compressed.wim /Compress:max
# Apply an imagedism /Apply-Image /ImageFile:<<WIM_PATH>> /Index:<<INDEX>> /ApplyDir:<<APPLY_DIR>>Step 11: PowerShell Equivalents
Section titled “Step 11: PowerShell Equivalents”Mapping Table
Section titled “Mapping Table”| Area | DISM Command | PowerShell Cmdlet | Purpose |
|---|---|---|---|
| Features (list/detail) | /Get-Features, /Get-FeatureInfo | Get-WindowsOptionalFeature | Inventory & details |
| Enable/Disable features | /Enable-Feature, /Disable-Feature | Enable-WindowsOptionalFeature, Disable-WindowsOptionalFeature | Toggle features |
| Capabilities (list/detail) | /Get-Capabilities, /Get-CapabilityInfo | Get-WindowsCapability | Inventory & details |
| Add/Remove capabilities | /Add-Capability, /Remove-Capability | Add-WindowsCapability, Remove-WindowsCapability | FoD management |
| Packages (info/add) | /Get-Packages, /Add-Package | Get-WindowsPackage, Add-WindowsPackage | Updates & LPs |
| Drivers (info/add/remove) | /Get-Drivers, /Add-Driver, /Remove-Driver | Get-WindowsDriver, Add-WindowsDriver, Remove-WindowsDriver | Primarily offline |
| Image info/mount | /Get-ImageInfo, /Mount-Wim, /Unmount-Wim | Get-WindowsImage, Mount-WindowsImage, Dismount-WindowsImage | WIM management |
11.1 Features
Section titled “11.1 Features”Get-WindowsOptionalFeature
| Option | Meaning | Example |
|---|---|---|
-Online | Running OS | Get-WindowsOptionalFeature -Online -FeatureName <<FEATURE_NAME>> |
-Path <<IMAGE_PATH>> | Offline image | Get-WindowsOptionalFeature -Path <<IMAGE_PATH>> |
-FeatureName <<FEATURE_NAME>> | Specific feature | -FeatureName NetFx3 |
# List all (online)Get-WindowsOptionalFeature -Online
# Detail (offline)Get-WindowsOptionalFeature -Path <<IMAGE_PATH>> -FeatureName <<FEATURE_NAME>>Enable-/Disable-WindowsOptionalFeature
| Option | Meaning | Example |
|---|---|---|
-Online / -Path <<IMAGE_PATH>> | Target | Enable-WindowsOptionalFeature -Online |
-FeatureName <<FEATURE_NAME>> | Feature name | -FeatureName NetFx3 |
-All | Include dependencies | -All |
-Source <<SOURCE_PATH>> | Payload source | -Source <<SOURCE_PATH>> |
# Enable NetFx3 with local sourceEnable-WindowsOptionalFeature -Online -FeatureName NetFx3 -All -Source <<SOURCE_PATH>>
# Disable SMB1Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol11.2 Capabilities
Section titled “11.2 Capabilities”Get-WindowsCapability
| Option | Meaning | Example |
|---|---|---|
-Online | Running OS | Get-WindowsCapability -Online |
-Name <<CAPABILITY_NAME>> | Supports wildcard | Get-WindowsCapability -Online -Name OpenSSH.* |
-Path <<IMAGE_PATH>> | Offline target | Get-WindowsCapability -Path <<IMAGE_PATH>> |
# List (online)Get-WindowsCapability -Online
# Filter single capabilityGet-WindowsCapability -Online -Name <<CAPABILITY_NAME>>Add-/Remove-WindowsCapability
| Option | Meaning | Example |
|---|---|---|
-Online / -Path <<IMAGE_PATH>> | Target | Add-WindowsCapability -Online |
-Name <<CAPABILITY_NAME>> | Capability name | -Name OpenSSH.Client~~~~0.0.1.0 |
-Source <<SOURCE_PATH>> | FoD source | -Source <<SOURCE_PATH>> |
# Add (online, with source if required)Add-WindowsCapability -Online -Name <<CAPABILITY_NAME>>
# RemoveRemove-WindowsCapability -Online -Name <<CAPABILITY_NAME>>11.3 Packages (updates & language packs)
Section titled “11.3 Packages (updates & language packs)”Get-WindowsPackage
| Option | Meaning | Example |
|---|---|---|
-Online / -Path <<IMAGE_PATH>> | Target | Get-WindowsPackage -Online |
-PackagePath <<PACKAGE_PATH>> | Info for a package | Get-WindowsPackage -Online -PackagePath <<PACKAGE_PATH>> |
# List installed packagesGet-WindowsPackage -OnlineAdd-WindowsPackage
| Option | Meaning | Example |
|---|---|---|
-Online / -Path <<IMAGE_PATH>> | Target | Add-WindowsPackage -Online -PackagePath <<PACKAGE_PATH>> |
-PackagePath <<PACKAGE_PATH>> | .cab (preferred) / .msu |
# Add an update (online)Add-WindowsPackage -Online -PackagePath <<PACKAGE_PATH>>
# Add a language pack (offline)Add-WindowsPackage -Path <<IMAGE_PATH>> -PackagePath <<LANG_PACK>>11.4 Drivers
Section titled “11.4 Drivers”Get-WindowsDriver
| Option | Meaning | Example |
|---|---|---|
-Online / -Path <<IMAGE_PATH>> | Target | Get-WindowsDriver -Path <<IMAGE_PATH>> |
-All | Show all drivers | -All |
# List drivers in an offline imageGet-WindowsDriver -Path <<IMAGE_PATH>> -AllAdd-/Remove-WindowsDriver
| Option | Meaning | Example |
|---|---|---|
-Path <<IMAGE_PATH>> | Target image | Add-WindowsDriver -Path <<IMAGE_PATH>> -Driver <<DRIVER_DIR>> -Recurse |
-Driver <<DRIVER_DIR>> | INF folder | |
-Recurse | Include subfolders | |
-Driver <<oem*.inf>> (Remove) | INF to remove | Remove-WindowsDriver -Path <<IMAGE_PATH>> -Driver oem1.inf |
# Add drivers (offline)Add-WindowsDriver -Path <<IMAGE_PATH>> -Driver <<DRIVER_DIR>> -Recurse
# Remove a driver (offline)Remove-WindowsDriver -Path <<IMAGE_PATH>> -Driver oem1.infImportant:
Add-/Remove-WindowsDriverdo not support-Online; use them against offline images.
11.5 Image Info & Mount
Section titled “11.5 Image Info & Mount”Get-WindowsImage
| Option | Meaning | Example |
|---|---|---|
-ImagePath <<WIM_PATH>> | WIM/ESD path | Get-WindowsImage -ImagePath <<WIM_PATH>> |
-Index <<INDEX>> | Specific index only | -Index <<INDEX>> |
# Show all indexes of install.wimGet-WindowsImage -ImagePath <<WIM_PATH>>Mount-/Dismount-WindowsImage
| Option | Meaning |
|---|---|
-ImagePath <<WIM_PATH>> | Source WIM |
-Index <<INDEX>> | Index to mount |
-Path <<MOUNT_DIR>> | Mount directory |
-ReadOnly | Read-only mount |
-ScratchDirectory <<SCRATCH_DIR>> | Working dir |
-Save (Dismount) | Save changes |
-Discard (Dismount) | Discard changes |
# MountMount-WindowsImage -ImagePath <<WIM_PATH>> -Index <<INDEX>> -Path <<MOUNT_DIR>>
# Save and dismountDismount-WindowsImage -Path <<MOUNT_DIR>> -SaveSummary
Section titled “Summary”- DISM: low-level management of OS components, WIM, updates, and drivers.
- PowerShell (DISM API): same scope with scriptability for inventory, selection, and automation.
- Capabilities (FoD): on-demand features (OpenSSH, RSAT, language packs).