Skip to content

Managing Windows Features and Images with DISM and PowerShell

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.

VariableExampleNotes
<<IMAGE_PATH>>C:\mount or E:\WindowsPath for /Image: (mounted offline Windows or another disk’s Windows directory)
<<FEATURE_NAME>>NetFx3Windows feature name
<<CAPABILITY_NAME>>OpenSSH.Client~~~~0.0.1.0Feature on Demand name (FoD)
<<WIM_PATH>>D:\sources\install.wimWIM/ESD image file
<<INDEX>>1Image index
<<MOUNT_DIR>>C:\mountMount point
<<DRIVER_DIR>>D:\driversFolder containing driver INF files
<<PACKAGE_PATH>>C:\Updates\kb5005565.cabUpdate package file
<<LANG_PACK>>C:\LP\ja-jp\lp.cabLanguage pack CAB
<<SOURCE_PATH>>D:\sources\sxsSource files (e.g., NetFx3)
<<APPLY_DIR>>C:\Apply/extract destination
<<SCRATCH_DIR>>C:\Temp\ScratchWorking directory
<<LOG_PATH>>C:\Temp\dism.logLog 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.

OptionMeaningExample
/OnlineCurrent running Windowsdism /Online /Cleanup-Image /CheckHealth
/Image:<<IMAGE_PATH>>Offline Windows or mounted imagedism /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)”

Enumerate available features and their state: Enabled / Disabled / DisabledWithPayloadRemoved.

OptionMeaningExample
/OnlineTarget running OSdism /Online /Get-Features
/Image:<<IMAGE_PATH>>Target offline imagedism /Image:C:\mount /Get-Features
/Get-FeaturesList featuresdism /Online /Get-Features /Format:Table
/Get-FeatureInfoDetail for one featuredism /Online /Get-FeatureInfo /FeatureName:NetFx3
/FeatureName:<<FEATURE_NAME>>Feature nameNetFx3
/Format:TableTabular outputdism /Online /Get-Features /Format:Table
Terminal window
# List all features and states
dism /Online /Get-Features /Format:Table
# Inspect a specific feature
dism /Online /Get-FeatureInfo /FeatureName:NetFx3

If 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)”

Enable/disable features such as .NET Framework 3.5 or SMB 1.0.

OptionMeaningExample
/OnlineTarget running OSdism /Online /Enable-Feature /FeatureName:NetFx3
/FeatureName:<<FEATURE_NAME>>Feature to manageNetFx3
/AllInclude dependencies
/Source:<<SOURCE_PATH>>Payload source when removeddism /Online /Enable-Feature /FeatureName:NetFx3 /Source:D:\sources\sxs
/LimitAccessDon’t use WU/WSUS
/Enable-FeatureEnabledism /Online /Enable-Feature /FeatureName:SMB1Protocol
/Disable-FeatureDisabledism /Online /Disable-Feature /FeatureName:SMB1Protocol
/LogPath:<<LOG_PATH>>Log output
Terminal window
# Enable .NET Framework 3.5 from local media without Internet
dism /Online /Enable-Feature /FeatureName:NetFx3 /All /LimitAccess /Source:<<SOURCE_PATH>> /LogPath:<<LOG_PATH>>
# Disable SMB1 for hardening
dism /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)”

List and inspect FoD (Features on Demand) such as RSAT, OpenSSH.Client, Language.Basic.

OptionMeaningExample
/OnlineRunning OSdism /Online /Get-Capabilities
/Image:<<IMAGE_PATH>>Offline imagedism /Image:C:\mount /Get-Capabilities
/Get-CapabilitiesList FoDdism /Online /Get-Capabilities /Format:Table
/Get-CapabilityInfoDetaildism /Online /Get-CapabilityInfo /CapabilityName:OpenSSH.Client~~~~0.0.1.0
/Format:TableTabular outputdism /Online /Get-Capabilities /Format:Table
Terminal window
# Enumerate FoD
dism /Online /Get-Capabilities /Format:Table
# Inspect one capability
dism /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)”

Add/remove on-demand components like OpenSSH or RSAT tools.

OptionMeaningExample
/OnlineRunning OSdism /Online /Add-Capability
/CapabilityName:<<CAPABILITY_NAME>>Capability to manageOpenSSH.Client~~~~0.0.1.0
/Source:<<SOURCE_PATH>>FoD ISO or sharedism /Online /Add-Capability /CapabilityName:OpenSSH.Client~~~~0.0.1.0 /Source:D:\ /LimitAccess
/LimitAccessUse only given source
/LogPath:<<LOG_PATH>>Log output
Terminal window
# Add OpenSSH.Client (online, from network or ISO)
dism /Online /Add-Capability /CapabilityName:<<CAPABILITY_NAME>> /LogPath:<<LOG_PATH>>
# Remove an unneeded RSAT tool
dism /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)”

Detect/repair WinSxS corruption and optimize disk usage.

OptionMeaningExample
/OnlineRunning OSdism /Online /Cleanup-Image /CheckHealth
/CheckHealthQuick check
/ScanHealthDeep scan
/RestoreHealthRepairdism /Online /Cleanup-Image /RestoreHealth
/Source:<<SOURCE_PATH>>Repair source
/LimitAccessAvoid WU
/StartComponentCleanupRemove superseded updates
/ResetBaseConsolidate (no rollback)
/AnalyzeComponentStoreSize analysis
Terminal window
# Quick corruption check
dism /Online /Cleanup-Image /CheckHealth
# Deep scan
dism /Online /Cleanup-Image /ScanHealth
# Repair with local source
dism /Online /Cleanup-Image /RestoreHealth /Source:<<SOURCE_PATH>> /LimitAccess /LogPath:<<LOG_PATH>>
# Cleanup and consolidate updates
dism /Online /Cleanup-Image /StartComponentCleanup /ResetBase /LogPath:<<LOG_PATH>>

OptionMeaningExample
/Get-ImageInfoShow images inside WIM/ESDdism /Get-ImageInfo /ImageFile:install.wim
/ImageFile:<<WIM_PATH>>WIM to inspect
/Index:<<INDEX>>Target index
/LogPath:<<LOG_PATH>>Log output
Terminal window
# Show editions and indexes in install.wim
dism /Get-ImageInfo /ImageFile:<<WIM_PATH>> /LogPath:<<LOG_PATH>>

OptionMeaningExample
/Mount-WimMount WIM
/WimFile:<<WIM_PATH>>Source WIM
/Index:<<INDEX>>Index to mount
/MountDir:<<MOUNT_DIR>>Mount directory
/ReadOnlyRead-only mount
/Get-MountedWimInfoShow mount status
/Unmount-WimUnmount
/CommitSave changes
/DiscardDiscard changes
Terminal window
# Mount for editing
dism /Mount-Wim /WimFile:<<WIM_PATH>> /Index:<<INDEX>> /MountDir:<<MOUNT_DIR>>
# Check current mounts
dism /Get-MountedWimInfo
# Save and unmount
dism /Unmount-Wim /MountDir:<<MOUNT_DIR>> /Commit

Step 9: Integrate Drivers, Packages, and Language Packs

Section titled “Step 9: Integrate Drivers, Packages, and Language Packs”
OptionMeaningExample
/OnlineRunning OS
/Image:<<MOUNT_DIR>>Offline image target
/Add-DriverAdd drivers
/Driver:<<DRIVER_DIR>>Folder containing INF
/RecurseInclude subfolders
/Add-PackageAdd updates or language packs
/PackagePath:<<PACKAGE_PATH>>Package path
/Set-AllIntl:ja-JPSet locale to Japanese

Notes:

  • /Add-Driver is offline only.
  • /Add-Package and /Set-AllIntl work online or offline.
Terminal window
# Integrate drivers
dism /Image:<<MOUNT_DIR>> /Add-Driver /Driver:<<DRIVER_DIR>> /Recurse
# Integrate an update
dism /Image:<<MOUNT_DIR>> /Add-Package /PackagePath:<<PACKAGE_PATH>>
# Add a language pack and set locale
dism /Image:<<MOUNT_DIR>> /Add-Package /PackagePath:<<LANG_PACK>>
dism /Image:<<MOUNT_DIR>> /Set-AllIntl:ja-JP

Step 10: Capture, Export, and Apply Images

Section titled “Step 10: Capture, Export, and Apply Images”
OptionMeaningExample
/Capture-ImageCapture a folder to WIM
/ImageFile:<<WIM_PATH>>Output WIM
/CaptureDir:<<APPLY_DIR>>Source directory
/Name:"<name>"Image name
/Export-ImageExport/compress existing WIM
/Apply-ImageApply WIM
/Compress:maxMax compression
/ApplyDir:<<APPLY_DIR>>Destination directory
Terminal window
# Capture current layout to WIM
dism /Capture-Image /ImageFile:D:\Custom.wim /CaptureDir:<<APPLY_DIR>> /Name:"Custom Image"
# Export with maximum compression
dism /Export-Image /SourceImageFile:<<WIM_PATH>> /SourceIndex:<<INDEX>> /DestinationImageFile:D:\install_compressed.wim /Compress:max
# Apply an image
dism /Apply-Image /ImageFile:<<WIM_PATH>> /Index:<<INDEX>> /ApplyDir:<<APPLY_DIR>>

AreaDISM CommandPowerShell CmdletPurpose
Features (list/detail)/Get-Features, /Get-FeatureInfoGet-WindowsOptionalFeatureInventory & details
Enable/Disable features/Enable-Feature, /Disable-FeatureEnable-WindowsOptionalFeature, Disable-WindowsOptionalFeatureToggle features
Capabilities (list/detail)/Get-Capabilities, /Get-CapabilityInfoGet-WindowsCapabilityInventory & details
Add/Remove capabilities/Add-Capability, /Remove-CapabilityAdd-WindowsCapability, Remove-WindowsCapabilityFoD management
Packages (info/add)/Get-Packages, /Add-PackageGet-WindowsPackage, Add-WindowsPackageUpdates & LPs
Drivers (info/add/remove)/Get-Drivers, /Add-Driver, /Remove-DriverGet-WindowsDriver, Add-WindowsDriver, Remove-WindowsDriverPrimarily offline
Image info/mount/Get-ImageInfo, /Mount-Wim, /Unmount-WimGet-WindowsImage, Mount-WindowsImage, Dismount-WindowsImageWIM management

Get-WindowsOptionalFeature

OptionMeaningExample
-OnlineRunning OSGet-WindowsOptionalFeature -Online -FeatureName <<FEATURE_NAME>>
-Path <<IMAGE_PATH>>Offline imageGet-WindowsOptionalFeature -Path <<IMAGE_PATH>>
-FeatureName <<FEATURE_NAME>>Specific feature-FeatureName NetFx3
Terminal window
# List all (online)
Get-WindowsOptionalFeature -Online
# Detail (offline)
Get-WindowsOptionalFeature -Path <<IMAGE_PATH>> -FeatureName <<FEATURE_NAME>>

Enable-/Disable-WindowsOptionalFeature

OptionMeaningExample
-Online / -Path <<IMAGE_PATH>>TargetEnable-WindowsOptionalFeature -Online
-FeatureName <<FEATURE_NAME>>Feature name-FeatureName NetFx3
-AllInclude dependencies-All
-Source <<SOURCE_PATH>>Payload source-Source <<SOURCE_PATH>>
Terminal window
# Enable NetFx3 with local source
Enable-WindowsOptionalFeature -Online -FeatureName NetFx3 -All -Source <<SOURCE_PATH>>
# Disable SMB1
Disable-WindowsOptionalFeature -Online -FeatureName SMB1Protocol

Get-WindowsCapability

OptionMeaningExample
-OnlineRunning OSGet-WindowsCapability -Online
-Name <<CAPABILITY_NAME>>Supports wildcardGet-WindowsCapability -Online -Name OpenSSH.*
-Path <<IMAGE_PATH>>Offline targetGet-WindowsCapability -Path <<IMAGE_PATH>>
Terminal window
# List (online)
Get-WindowsCapability -Online
# Filter single capability
Get-WindowsCapability -Online -Name <<CAPABILITY_NAME>>

Add-/Remove-WindowsCapability

OptionMeaningExample
-Online / -Path <<IMAGE_PATH>>TargetAdd-WindowsCapability -Online
-Name <<CAPABILITY_NAME>>Capability name-Name OpenSSH.Client~~~~0.0.1.0
-Source <<SOURCE_PATH>>FoD source-Source <<SOURCE_PATH>>
Terminal window
# Add (online, with source if required)
Add-WindowsCapability -Online -Name <<CAPABILITY_NAME>>
# Remove
Remove-WindowsCapability -Online -Name <<CAPABILITY_NAME>>

Get-WindowsPackage

OptionMeaningExample
-Online / -Path <<IMAGE_PATH>>TargetGet-WindowsPackage -Online
-PackagePath <<PACKAGE_PATH>>Info for a packageGet-WindowsPackage -Online -PackagePath <<PACKAGE_PATH>>
Terminal window
# List installed packages
Get-WindowsPackage -Online

Add-WindowsPackage

OptionMeaningExample
-Online / -Path <<IMAGE_PATH>>TargetAdd-WindowsPackage -Online -PackagePath <<PACKAGE_PATH>>
-PackagePath <<PACKAGE_PATH>>.cab (preferred) / .msu
Terminal window
# Add an update (online)
Add-WindowsPackage -Online -PackagePath <<PACKAGE_PATH>>
# Add a language pack (offline)
Add-WindowsPackage -Path <<IMAGE_PATH>> -PackagePath <<LANG_PACK>>

Get-WindowsDriver

OptionMeaningExample
-Online / -Path <<IMAGE_PATH>>TargetGet-WindowsDriver -Path <<IMAGE_PATH>>
-AllShow all drivers-All
Terminal window
# List drivers in an offline image
Get-WindowsDriver -Path <<IMAGE_PATH>> -All

Add-/Remove-WindowsDriver

OptionMeaningExample
-Path <<IMAGE_PATH>>Target imageAdd-WindowsDriver -Path <<IMAGE_PATH>> -Driver <<DRIVER_DIR>> -Recurse
-Driver <<DRIVER_DIR>>INF folder
-RecurseInclude subfolders
-Driver <<oem*.inf>> (Remove)INF to removeRemove-WindowsDriver -Path <<IMAGE_PATH>> -Driver oem1.inf
Terminal window
# Add drivers (offline)
Add-WindowsDriver -Path <<IMAGE_PATH>> -Driver <<DRIVER_DIR>> -Recurse
# Remove a driver (offline)
Remove-WindowsDriver -Path <<IMAGE_PATH>> -Driver oem1.inf

Important: Add-/Remove-WindowsDriver do not support -Online; use them against offline images.


Get-WindowsImage

OptionMeaningExample
-ImagePath <<WIM_PATH>>WIM/ESD pathGet-WindowsImage -ImagePath <<WIM_PATH>>
-Index <<INDEX>>Specific index only-Index <<INDEX>>
Terminal window
# Show all indexes of install.wim
Get-WindowsImage -ImagePath <<WIM_PATH>>

Mount-/Dismount-WindowsImage

OptionMeaning
-ImagePath <<WIM_PATH>>Source WIM
-Index <<INDEX>>Index to mount
-Path <<MOUNT_DIR>>Mount directory
-ReadOnlyRead-only mount
-ScratchDirectory <<SCRATCH_DIR>>Working dir
-Save (Dismount)Save changes
-Discard (Dismount)Discard changes
Terminal window
# Mount
Mount-WindowsImage -ImagePath <<WIM_PATH>> -Index <<INDEX>> -Path <<MOUNT_DIR>>
# Save and dismount
Dismount-WindowsImage -Path <<MOUNT_DIR>> -Save

  • 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).