Enable-PEWimPSGallery

The Function

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

Results

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