WinPE: Adding Windows PowerShell support to Windows PE

Prepare a local copy of the Windows PE files

On a technician PC:

  1. Download and install the Windows Assessment and Deployment Kit (ADK) and matching WinPE add-on.

For ADK versions prior to Windows 10, version 1809, WinPE is part of the ADK and isn't a separate add-on.

  1. Start the Deployment and Imaging Tools Environment as an administrator.
  2. Create a working copy of the Windows PE files:

Windows Command Prompt

3. copype amd64 C:\WinPE_amd64_PS

  1. See CopyPE command line options for more information.

Add WinPE PowerShell optional components

Now that you have a working set of files that includes a WinPE image, you can mount the image and add the WinPE optional components required to add PowerShell.

Use the following script to mount the Windows image, add the Windows PE optional components for Windows PowerShell, and to unmount the image.

  1. Mount your WinPE image:

Windows Command Prompt

Dism /Mount-Image /ImageFile:"C:\WinPE_amd64_PS\media\sources\boot.wim" /Index:1 /MountDir:"C:\WinPE_amd64_PS\mount"

  • Add the required optional components to your image. The example below shows the components to add to an image with the en-US language. If your image has additional languages, also add the versions of the packages below for the other languages included in your image.

Windows Command Prompt

·  Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab"Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WMI_en-us.cab"Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-NetFX.cab"Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-NetFX_en-us.cab"Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-Scripting.cab"Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-Scripting_en-us.cab"Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PowerShell.cab"Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-PowerShell_en-us.cab"Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-StorageWMI.cab"Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-StorageWMI_en-us.cab"Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-DismCmdlets.cab"Dism /Add-Package /Image:"C:\WinPE_amd64_PS\mount" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-DismCmdlets_en-us.cab"

  • Unmount your image, committing changes:

Windows Command Prompt

Dism /Unmount-Image /MountDir:C:\WinPE_amd64_PS\mount /Commit

 

Install this version of Windows PE to a USB key or a ISO file

Now that you have a WinPE image that includes PowerShell, you can create bootable WinPE media.

  1. Insert a USB drive into your technician PC.
  2. Run MakeWinPEMedia to create a bootable USB key that includes your WinPE image:

Windows Command Prompt

MakeWinPEMedia /UFD C:\WinPE_amd64_PS F:

MakeWinPEMedia /ISO C:\WinPE_amd64_PS C:\WinPE_amd64_PS\WinPE_amd64.iso

阅读剩余
THE END