This weekend I stumbled across an issue when trying to mount a driver package (WIM file) in WinPE via the Mount-WindowsImage cmdlet, part of the Dism PowerShell module from WinPE. The error that was shown was:
Mount-WindowsImage : The 'Mount-WindowsImage' command was found in the module 'Dism', but the module could not be loaded.
The Real Error
After trapping the Mount-WindowsImage command in a try/catch block, it showed that the real error was related to that the Dism module couldn't be imported. The error was:
Could not load file or assembly 'file:///X:\Windows\system32\WindowsPowerShell\v1.0\Modules\Dism\Microsoft.Dism.PowerShell.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
Only at PXE boot
Interesting enough, the error only happened when PXE booting my machines, not when using a boot media (ISO) of the same boot image. After some research it turned out that somehow the Microsoft.Dism.PowerShell.dll file got corrupted during boot, which should be impossible, but still happened. Big thanks to John Wall at Just Another IT Blog for leading me in the right direction.
Workaround
I'm still working on figuring out the root cause of why the Microsoft.Dism.PowerShell.dll file is getting corrupted during PXE boot (only), but for now I simply replaced the file early in the task sequence.
Note #1: Just replacing the file was not enough, I had to delete the existing one first.
Note #2: To make sure PowerShell didn't try importing the module and locking it from deletion, I used two run command line actions that used cmd.exe
Add three actions to your task sequence:
1. Connect to Network Folder (where you have a working copy of the Microsoft.Dism.PowerShell.dll)
2. Run Command Line action (I named itDelete Corrupt Dism Module), with the following command:
cmd /c del X:\Windows\system32\WindowsPowerShell\v1.0\Modules\Dism\Microsoft.Dism.PowerShell.dll
3. Run Command Line action (I named it Copy Dism Module), with the following command:
xcopy H:\WinPE_PowerShell_Modules_ADK_21H2\Dism\Microsoft.Dism.PowerShell.dll X:\Windows\system32\WindowsPowerShell\v1.0\Modules\Dism\ /y

Thank you Johan. In my company the TS is very large and nested. Many times the TS becomes corrupt during saves. Additional actions are difficult to add. Finding out why the .dll is becoming corrupt is extremely important. Network constraints here reduce the PXE viability to near 0 here and EMEA and AIPAC regions can only use Litetouch USB media methods.
Hi William,
Yes, large task sequences are still a problem in ConfigMgr, even though the support has improved over the years. I often work with customers simplifying task sequences by breaking out complex logic into scripts, rather than having it in the task sequence actions, conditions, etc. As far as why the cmdlet gets corrupted, I haven't figured out why yet. But will certainly update the post once I do.