Powershell script/tool to get OS image information from WIM file


This Script/Function/tool returns information on images contained in a WIM file. For more information on Wim files see this link. WIM file information is available via the Deployment Image Servicing and Management (DISM) Command-Line tool. For more information on Dism.exe see this link.

The DISM tool returns the information as text. This script/function/tool extracts information from the Dism.exe output text and returns a PS Object containing the same information. This makes it easily available for further processing or reporting. Similar information is available from the Get-WindowsImage Cmdlet of the DISM PS module,   but this script/tool returns more details.

This script can be downloaded from the Microsoft Script Center Repository.

Example:

Get-WimImage -WimPath H:\sources\install.wim

where h:\sources\install.wim is the path to the WIM file. Output will look like:

Wim2

Example:

$Images = Get-WimImage H:\sources\install.wim | Select Index,Name,Size,Version,Languages
$Images | FT -a # Output to console
$Images | Out-GridView # Output to Powershell_ISE Grid View
$Images | Export-Csv .\Images.csv -NoType # Export to CSV file

In this example, some properties are selected, and displayed in different formats.

Wim3

Example:

$DriveLetters = (Get-Volume).DriveLetter
$ISO = Mount-DiskImage -ImagePath E:\Install\ISO\Win10\en_windows_server_technical_preview_x64_dvd_5554304.iso -PassThru
$ISODriveLetter = (Compare-Object -ReferenceObject $DriveLetters -DifferenceObject (Get-Volume).DriveLetter).InputObject
$Images = Get-WimImage “$($ISODriveLetter):\sources\install.wim”
Dismount-DiskImage $ISO.ImagePath
$SelectedProps = $Images | Select Index,Name,
@{N=’Size(GB)’;E={[Math]::Round($_.Size/1GB,2)}},Version,Languages

$SelectedProps | FT -a # Output to console
$SelectedProps | Out-GridView # Output to Powershell_ISE Grid View
$SelectedProps | Export-Csv .\Images.csv -NoType

This example mounts the E:\Install\ISO\Win10\en_windows_server_technical_preview_x64_dvd_5554304.iso file, gets the information of the images it contains, dismounts it, presents that information in different formats, and saves it to CSV file.

Wim4

Wim1

Example:

$ISOFolder = ‘e:\install\ISO\win10’
$Images = @()
(Get-ChildItem -Path $ISOFolder -Filter *.iso).FullName | % {
    $DriveLetters = (Get-Volume).DriveLetter
    $ISO = Mount-DiskImage -ImagePath $_ -PassThru
    $ISODriveLetter = (Compare-Object -ReferenceObject $DriveLetters -DifferenceObject (Get-Volume).DriveLetter).InputObject
    $Result = Get-WimImage “$($ISODriveLetter):\sources\install.wim”
    $Result | Add-Member ‘ISOFile’ (Split-Path -Path $ISO.ImagePath -Leaf)
    $Images += $Result
    Dismount-DiskImage $ISO.ImagePath
    Start-Sleep -Seconds 1
}
$Images | Select ISOFile,Index,Name,
@{N=’Size(GB)’;E={[Math]::Round($_.Size/1GB,2)}},Version,Languages | FT -a

This example aggregates results from several ISO files:

Wim5

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s