Problems loading a module from a remote session

Understand why loading powershell modules from a restricted endpoint has problems.

John Savill

April 15, 2017

1 Min Read
Problems loading a module from a remote session

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

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like