PowerShell Gallery in WinPE

March 8, 2021

It would be nice if you could install PowerShell Modules in WinPE from PowerShell Gallery ... here is how

No PackageManagement

The first problem is that even though PowerShellGet is installed in WinPE, PackageManagement is not. This leads to a Chicken and Egg situation where you can't install PackageManagement from PowerShell Gallery until PackageManagement is installed

No LocalAppData

So you manage to get a copy of the PackageManagement PowerShell Module saved in your WinPE WIM, but things still don't work. This is because WinPE does not contain a Volatile Environment at HKEY_CURRENT_USER\Volatile Environment

Specifically, what is missing is LOCALAPPDATA

The Function

I ended up writing a function that will make these changes for you. Feel free to have a look

What this function does is

  1. Mounts a WinPE WIM

  2. Adds the missing Volatile Environment (in Current Environment)

  3. Saves PackageManagenment and PowerShellGet Modules from PowerShell Gallery in the WIM

  4. Dismount and Save the WinPE WIM


After modifying the WIM, I can test the changes by creating an ISO (or you can USB, whatever). Works like a champ!

Last updated