-
-
Save thisislukasbenz/a825068a96d2ba6741d9190f2a7fe8b8 to your computer and use it in GitHub Desktop.
Fix Appx in PSRemoting for Server 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Server 2025 fails to run Get-AppxPackage and other DISM module commands in | |
# a PSRemoting (psrp) session as it has a dependency on some dll's not present | |
# in the GAC and only in the powershell.exe directory. As PSRP runs through | |
# wsmprovhost.exe, it fails to find those dlls. This hack will manually load | |
# the 4 required dlls into the GAC. This is a hack and should be removed in the | |
# future if MS fix their bug on 2025. | |
Add-Type -AssemblyName "System.EnterpriseServices" | |
$publish = [System.EnterpriseServices.Internal.Publish]::new() | |
@( | |
'System.Numerics.Vectors.dll', | |
'System.Runtime.CompilerServices.Unsafe.dll', | |
'System.Security.Principal.Windows.dll', | |
'System.Memory.dll' | |
) | ForEach-Object { | |
$dllPath = "$env:SystemRoot\System32\WindowsPowerShell\v1.0\$_" | |
$publish.GacInstall($dllPath) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment