PowerShell Gallery in WinPE
March 8, 2021
Last updated
March 8, 2021
Last updated
It would be nice if you could install PowerShell Modules in WinPE from PowerShell Gallery ... here is how
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
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
I ended up writing a function that will make these changes for you. Feel free to have a look
What this function does is
Mounts a WinPE WIM
Adds the missing Volatile Environment (in Current Environment)
Saves PackageManagenment and PowerShellGet Modules from PowerShell Gallery in the WIM
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!