Problems loading a module from a remote session
Understand why loading powershell modules from a restricted endpoint has problems.
April 15, 2017
Q. I'm trying to import a module from a remote PowerShell session that is a restricted endpoint but it does not work.
A. This seems to be a limitation of restricted endpoints. Normally I could perform:
Import-Module -Name ActiveDirectory -PSSession $adsess
However if the session if to a restricted endpoint the command will fail. The only workaround seems to be to import the session and then utilize the modules via the session, for example:
sess = New-PSSession -ComputerName -ConfigurationName RestrictEnd -Credential $cred -Authentication Credssp
$imsess = Import-PSSession -Session $sess -AllowClobber
Get-command -module $imsess
Remove-PSSession $sess
About the Author
You May Also Like