Edit-ADKwinpe.wim

This really is a great function if you are looking to speed things up with ADK's WinPE.wim. I end up ALWAYS adding PowerShell to WinPE and that takes time with .NET and all the other packages

What this function will do is back up the existing ADK winpe.wim, and modify the amd64 winpe.wim with the following changes

  • All the cool ADK Packages for PowerShell support

  • cURL.exe will be added copied (if you have it in your host OS)

  • PowerShell ExecutionPolicy will be set to Bypass

  • Volatile Paths will be added (APPDATA, LOCALAPPDATA)

    • Required for PackageManagement

  • PackageManagement

    • Required for PowerShell Gallery

  • PowerShellGet

    • Required for PowerShell Gallery

I made sure to add a TimeSpan to show how much time you will save every time you create WinPE going forward. In my case, 4.5 minutes! Now before you say anything, yes it is ugly with everything VERBOSE, but I believe that if you are editing your master winpe.wim, you better make sure you know what is happening to it

PS C:\WINDOWS\system32> Edit-ADKWinPE.wim

VERBOSE: Performing the operation "Copy File" on target "Item: C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\en-us\winpe.wim Destination: C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows
Preinstallation Environment\amd64\en-us\winpe.bak".
VERBOSE: C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\en-us\winpe.wim
VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab

Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WMI_en-us.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-HTA.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-HTA_en-us.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-NetFx.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-NetFx_en-us.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-Scripting.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-Scripting_en-us.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PowerShell.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-PowerShell_en-us.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-SecureStartup.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-SecureStartup_en-us.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-DismCmdlets.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-DismCmdlets_en-us.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-Dot3Svc.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-Dot3Svc_en-us.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-EnhancedStorage.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-EnhancedStorage_en-us.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-FMAPI.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-GamingPeripherals.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PPPoE.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-PPPoE_en-us.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PlatformId.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PmemCmdlets.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-PmemCmdlets_en-us.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-RNDIS.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-RNDIS_en-us.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-SecureBootCmdlets.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-StorageWMI.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-StorageWMI_en-us.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WDS-Tools.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Target Image Version 10.0.19041.1
VERBOSE: Successfully added package C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\en-us\WinPE-WDS-Tools_en-us.cab
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Adding curl.exe to C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396

VERBOSE: Setting PowerShell ExecutionPolicy to Bypass in C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
VERBOSE: Path: C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396

LastWriteTime : 3/15/2021 9:19:50 PM
Length        : 0
Name          : Set-ExecutionPolicy.inf

VERBOSE: Target Image Version 10.0.19041.1
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False


MountPath   : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
ImagePath   : C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\en-us\winpe.wim
ImageIndex  : 1
MountMode   : ReadWrite
MountStatus : Ok

VERBOSE: Enabling PowerShell Gallery support in C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
VERBOSE: Path: C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396

LastWriteTime : 3/15/2021 9:19:51 PM
Length        : 0
Name          : Set-WinPEEnvironment.inf

VERBOSE: Target Image Version 10.0.19041.1
Path          : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
Online        : False
RestartNeeded : False

VERBOSE: Saving PackageManagement to C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396\Program Files\WindowsPowerShell\Modules
VERBOSE: Populating RepositorySourceLocation property for module PackageManagement.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\PackageManagement.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module PackageManagement.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.5\PackageManagement.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module PackageManagement.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.4\PackageManagement.psm1'.
VERBOSE: Populating RepositorySourceLocation property for module PackageManagement.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.1.1.0\PackageManagement.psm1'.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\PackageManagement.psd1'.
VERBOSE: Loading 'FormatsToProcess' from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\PackageManagement.format.ps1xml'.
VERBOSE: Populating RepositorySourceLocation property for module PackageManagement.
VERBOSE: Loading module from path 'C:\Program Files\WindowsPowerShell\Modules\PackageManagement\1.4.7\PackageManagement.psm1'.
VERBOSE: Exporting cmdlet 'Find-Package'.
VERBOSE: Exporting cmdlet 'Find-PackageProvider'.
VERBOSE: Exporting cmdlet 'Get-Package'.
VERBOSE: Exporting cmdlet 'Get-PackageProvider'.
VERBOSE: Exporting cmdlet 'Get-PackageSource'.
VERBOSE: Exporting cmdlet 'Import-PackageProvider'.
VERBOSE: Exporting cmdlet 'Install-Package'.
VERBOSE: Exporting cmdlet 'Install-PackageProvider'.
VERBOSE: Exporting cmdlet 'Register-PackageSource'.
VERBOSE: Exporting cmdlet 'Save-Package'.
VERBOSE: Exporting cmdlet 'Set-PackageSource'.
VERBOSE: Exporting cmdlet 'Uninstall-Package'.
VERBOSE: Exporting cmdlet 'Unregister-PackageSource'.
VERBOSE: Importing cmdlet 'Find-Package'.
VERBOSE: Importing cmdlet 'Find-PackageProvider'.
VERBOSE: Importing cmdlet 'Get-Package'.
VERBOSE: Importing cmdlet 'Get-PackageProvider'.
VERBOSE: Importing cmdlet 'Get-PackageSource'.
VERBOSE: Importing cmdlet 'Import-PackageProvider'.
VERBOSE: Importing cmdlet 'Install-Package'.
VERBOSE: Importing cmdlet 'Install-PackageProvider'.
VERBOSE: Importing cmdlet 'Register-PackageSource'.
VERBOSE: Importing cmdlet 'Save-Package'.
VERBOSE: Importing cmdlet 'Set-PackageSource'.
VERBOSE: Importing cmdlet 'Uninstall-Package'.
VERBOSE: Importing cmdlet 'Unregister-PackageSource'.
VERBOSE: Saving PowerShellGet to C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396\Program Files\WindowsPowerShell\Modules

MountPath   : C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
ImagePath   : C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\en-us\winpe.wim
ImageIndex  : 1
MountMode   : ReadWrite
MountStatus : Ok

VERBOSE: Path: C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396
VERBOSE: Performing the operation "Dismount-MyWindowsImage -Save" on target "C:\Users\SeguraOSD\AppData\Local\Temp\Mount1574955396".
=========================================================================
2021-03-15-212107 Edit-AdkWinPE.wim Completed in 04 minutes 33 seconds

Now with the edited winpe.wim it shaves off time considerably going forward with anything, MDT, MEM CM, or even other scripts. In the case below I was able to all of this in 1m:32s !

  • Copies the winpe.wim

  • Mounts winpe.wim

  • Adds the same packages as Edit-AdkWinPE.wim ... so it basically skips through the process

  • Dismounts winpe.wim

  • Creates an ISO

Last updated