Powershell V4.0 updates to the Dism module
Windows Server 2012 R2 and Windows 8.1 is RTM and that means PowerShell 4 is as well!
PowerShell 4.0 brings a whole bunch of new treats to the table, one of the most notable being Desired State Configuration which I will come back to in a later post, but there is also a bunch of other news, one of them being a few new cmdlets in the Dism module.
The following commandlets are new in the Dism module and worth noting are the three parameters -LogPath -LogLevel and -ScratchDirectory which is available for all cmdlets below.
-LogPath lets us specify where the logs should be written. The default directory is %WINDIR%LogsDismdism.log but I imagine that logging to a remote share like “ServerDismLogs$SerialnumberDism.log” would be highly convinient.
-LogLevel lets us specify a number from 1 to 4:
1 |
2 |
3 |
4 |
If the parameter is left out, default value is 3.
-ScratchDirectory is used to specify a temp directory that will be used for extracting files.
Expand-WindowsImage
Used to apply an image from a .wim-file directly from PowerShell, similar to using Dism.exe /apply-image.
The required parameters are -ApplyPath which specifies where the image should be applied, -ImagePath that specifies which image that should be applied and either -Index or -Name to specify which image index number or image name in the wim-file that should be used.
Export-WindowsImage
Exports a copy of a image to another image file.
Get-WindowsImageContent
This is the powershell version of Dism /List-Image, it will simply list all files and folders in the specified image. Worth noting is that doing this in PowerShell will return an array of strings.
New-WindowsImage
Used to capture an Image in PowerShell, similar to Dism /Capture-Image
Remove-WindowsImage
Removes an image from a specified image file.
Set-AppXProvisionedDataFile
Used to add custom data into a specified app package (.appx). An app package is used to provision Windows 8-style applications (also known as Metro-apps).
Split-WindowsImage
Used to split a wim-file into multiple readonly swm-files.
Great command to use when applying large images from USB onto UEFI-booted computers since UEFI requires boot from FAT32 and FAT32 only supports single files up to 4GB.