Problems loading a module from a remote session

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 <target> -ConfigurationName RestrictEnd -Credential $cred -Authentication Credssp
$imsess = Import-PSSession -Session $sess -AllowClobber
Get-command -module $imsess

Remove-PSSession $sess

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.