An Engineers Notebook

Using PowerShell to Add Drivers / Packages / Install Roles and Features in a .wim file

The following reference folders that contain the relevent drivers/packages. Ensure you have the driver/package in the right location e.g. .drivers

### DISM - Deployment Image Servicing and Management PowerShell Cmdlets ###
## .wim ##
# view cmdlets in DISM module
Get-Command -Module DISM
# view images within a .wim
Get-WindowsImage -ImagePath .imagesinstall.wim
Get-WindowsImage -ImagePath .imagesnanoserver.wim
# mount server core datacenter image
Mount-WindowsImage -ImagePath .imagesinstall.wim -Path .mount -Index 3
# add drivers (.inf)
Get-WindowsDriver -Path .mount
Add-WindowsDriver -Path .mount -Driver .driversiaStorAC.inf
# add packages (.msu or .cab)
Get-WindowsPackage -Path .mount
Add-WindowsPackage -Path .mount -PackagePath .updateswindows10.0-kb3150513.msu
# install roles and features
Get-WindowsOptionalFeature -Path .mount -FeatureName dhcpserver
Enable-WindowsOptionalFeature -Path .mount -FeatureName dhcpserver
Disable-WindowsOptionalFeature -Path .mount -FeatureName dhcpserver
# dismount and commit changes
Dismount-WindowsImage -Path .mount -Save

## .vhd/vhdx ##
# mount nano server datacenter vhd
Mount-WindowsImage -ImagePath .imagenanoserver.wim -Path .mount -Index 2
# add iis package
Add-WindowsPackage -Path .mount -PackagePath d:nanoserverpackagesmicrosoft-nanoserver-iis-package.cab
# dismount and commit changes
Dismount-WindowsImage -Path .mount -Save

 

 

Leave a Reply

Your email address will not be published.