Introduction
The Install-WindowsImage PowerShell script uses the wimgapi.dll in Windows 7 or Windows Server 2008 R2 to apply a Windows image in a .wim file to a specified location. The script can be used to apply a Windows 7 or Windows Server 2008 R2 .wim image to a Virtual Hard Disk (VHD) used for native VHD boot or to boot in a Hyper-V virtual machine.
The
Using Install-WindowsImage document provides a step-by-step walkthrough of how to create a VHD in Windows 7 and use Install-WindowsImage to apply an image for native boot. The document is available on the Downloads tab in Microsoft Office Word 2007 (.docx) or Protable Documentation Format (.pdf).
A related tool, WIM2VHD, is available from the MSDN Code Gallery that automates the steps of VHD creation and applying a .wim image using the Imagex deployment tool from the Windows Automated Installation Kit (AIK).
Requirements
• A machine running Windows 7 or Windows Server 2008 R2.
• Windows 7 or Windows Server 2008 R2 installation media.
or
• A Windows 7 or Windows Server 2008 R2 .wim image captured from a reference machine.
Additional Resources
What's New in Windows 7 Virtual Hard Disks http://technet.microsoft.com/en-us/library/dd440864.aspx Windows 7 VHD Boot Demonstration Videohttp://technet.microsoft.com/en-us/windows/dd758779.aspx Windows Automated Installation Kit (AIK) for Windows 7 for tools and documentation designed for IT Professionals to deploy Windows
http://technet.microsoft.com/en-us/library/dd349343(WS.10).aspx WIM2VHD on MSDN Code Gallery
http://code.msdn.microsoft.com/wim2vhd Scripting with PowerShellhttp://www.microsoft.com/technet/scriptcenter/hubs/msh.mspx
Usage
The usage help text for Install-WindowsImage.ps1 is the following:
PS > help .\Install-WindowsImage.ps1 –detailed
NAME
Install-WindowsImage.ps1
SYNOPSIS
Lists or applies Windows Images in .WIM containers.
SYNTAX
C:\Vhd\Install-WindowsImage.ps1 -WIM <String> [<CommonParameters>]
C:\Vhd\Install-WindowsImage.ps1 -WIM <String> -Apply -Index <Int32> -Destination <String> [<CommonParameters>]
DESCRIPTION
PARAMETERS
-WIM <String>
Specifies the .WIM file to examine and/or apply images from.
-Apply [<SwitchParameter>]
Specifies that the specified image index should be applied to the specified Destination.
-Index <Int32>
Specifies the image index of the Windows Image to apply to the specified Destination.
-Destination <String>
The drive or folder to apply the specified Windows Image to.
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".
-------------------------- EXAMPLE 1 --------------------------
C:\PS>This example will list the available images in the D:\Sources\Install.wim container.
.\Install-WindowsImage.ps1 -WIM D:\Sources\Install.wim
-------------------------- EXAMPLE 2 --------------------------
C:\PS>This example will apply image number 8 from D:\Sources\Install.wim to V:\.
.\Install-WindowsImage.ps1 -WIM D:\Sources\Install.wim -Apply -Index 8 -Destination V:\