Skip navigation
Import PowerShell module from a remote machine

Import PowerShell module from a remote machine

Q. How can I import a PowerShell module from a remote machine?

A. It is very common to create a remote session on a machine and in that session you can then use the modules on that remote server. Another option is to import remote modules on to your local machine via the remote session. When that module is utilized on the local machine it actually executes via the remote session.

To do this create a session then import a module via the session, for example:

$adsess = New-PSSession -ComputerName savdaldc01
Import-Module -Name ActiveDirectory -PSSession $adsess
Get-ADUser -Filter *
Remove-Module ActiveDirectory

It's also possible to prefix modules loaded from remote servers to differentiate from local modules, e.g.

Import-Module -Name ActiveDirectory -PSSession $adsess -Prefix OnDC
Get-OnDCADUser -Filter * #I don't have regular Get-ADUser anymore
Remove-Module ActiveDirectory
Remove-PSSession $adsess 

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.