Import PowerShell module from a remote machine
Load a PowerShell module from a remote server.
March 20, 2017
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-Module
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
About the Author
You May Also Like