Exporting ActiveDirectory Module

To manage users and computers in your Active Directory from PowerShell, you need the ActiveDirectory module which comes as part of the free RSAT tools from Microsoft.

Provided you are domain administrator and have remoting access to your domain controller, you can also export the ActiveDirectory module from your DC, and use it locally via implicit remoting.

Here is how you do this:

$DC='dc1'# rename, must be name of one of your domain controllers
# create a session
$s=New-PSSession-ComputerNamedc1# export the ActiveDirectory module from the server to a local module "ADStuff"
Export-PSSession-Session$s-OutputModuleADStuff-ModuleActiveDirectory-AllowClobber-Force# remove session
Remove-PSSession$s

When you run this code, and you have permission to connect to your DC, the code creates a new local module named “ADStuff” which contains all the AD cmdlets. You can now use the AD cmdlets through implicit remoting and without the need to install RSAT tools.

Caveat: since all cmdlets in reality run on the server, all results are serialized before they get to you. This changes the object type, so when you pipe data from one AD cmdlet to another, you may experience binding issues. As long as you use cmdlets outside of a pipeline, all is fine.