comments 3

Deploy PowerShell ActiveDirectory Module without installing the remote server tools

Make use of the PowerShell ActiveDirectory module always required to install the Remote Server Administration Tools.
That sucks! We want it as simple as executing a script.

Let’s build a PowerShell script that adds the ActiveDirectory Powershell module on any computer.

For this setup we require one file and one folder (with its content).

The file is: Microsoft.ActiveDirectory.Management.dll (it’s stored somwhere here: C:\Windows\Microsoft.NET\assembly\GAC_64\Microsoft.ActiveDirectory.Management)
And the folder is: C:\Windows\System32\WindowsPowerShell\v1.0\Modules\ActiveDirectory

Ironically you’ll find these files on a computer where the Remote Server Administration Tools are installed.

Now create folder structure as below and place the files inside:

  • …/yourfolder/
    • ActiveDirectory/
      • Place the folder files here
    • Microsoft.ActiveDirectory.Management.dll
    • Install-ActiveDirectoryModule.ps1

Then update the Install-ActiveDirectoryModule.ps1 file with the content below:

function Add-AssemblyToGlobalAssemblyCache{

	    Installing Assemblies to Global Assembly Cache (GAC)

	    This script is an alternative to the GACUTIL available in 
	    the .NET Framework SDK. It will put the specified assembly
	    in the GAC.

        Add-AssemblyToGlobalAssemblyCache -AssemblyName C:\Temp\MyWorkflow.dll
        This command will install the file MyWorkflow.dll from the C:\Temp directory in the GAC.

        Dir C:\MyWorkflowAssemblies | % {$_.Fullname} | Add-AssemblyToGlobalAssemblyCache
        You can also pass the assembly filenames through the pipeline making it easy
        to install several assemblies in one run. The command abobe  will install 
        all assemblies from the directory C:\MyWorkflowAssemblies, run this command

    .PARAMETER AssemblyName
	    Full path of the assembly file

    .PARAMETER PassThru
        If set, script will pass the filename given through the pipeline    

	    April 18, 2012 | Soren Granfeldt ( 
		    - initial version


	    [Parameter(Mandatory=$true, ValueFromPipeline=$True,ValueFromPipelineByPropertyName=$True)]
	    [string] $Name = "",

	if ($null -eq ([AppDomain]::CurrentDomain.GetAssemblies() |? { $_.FullName -eq "System.EnterpriseServices, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" })){
		[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a") | Out-Null
	$PublishObject = New-Object System.EnterpriseServices.Internal.Publish
	foreach($Assembly in $Name){

        if ( -not (Test-Path $Assembly -type Leaf)){
            throw "The assembly '$Assembly' does not exist."

        $LoadedAssembly = [System.Reflection.Assembly]::LoadFile($Assembly)

        if ($LoadedAssembly.GetName().GetPublicKey().Length -eq 0){
            throw "The assembly '$Assembly' must be strongly signed."
        Write-Host "Installing: $Assembly"


$moduledirectory = "C:\Windows\System32\WindowsPowerShell\v1.0\Modules\ActiveDirectory"
$basepath = Split-Path -parent $MyInvocation.MyCommand.Definition

if(-not (Test-Path -Path $moduledirectory)){
    New-Item -Path $moduledirectory -ItemType directory | Out-Null

Copy-Item -Path (Join-Path $basepath "\ActiveDirectory\*") -Destination $moduledirectory -Recurse -Force

Add-AssemblyToGlobalAssemblyCache -Name (Join-Path $basepath "Microsoft.ActiveDirectory.Management.dll")

Got it! When executing the Install-ActiveDirectoryModule.ps1 on another computer it should install the PowerShell ActiveDirectory module.


  1. Janik Vonrotz

    Hey Gary, a lot has changed with PowerShell since 2015. I’m not sure if this is still a feasable solution. As far as I can recall this was a workaround and I assume there are better solutions now. But you can give it a try, it should work with Windows 7 64-bit.

  2. James

    Just wanted to mention that this worked fantastic on our windows 10 1709 issue since MS took away the ability to manage the installed features of RSAT (we need the powershell extension to perform certain management tasks during OSD) This is much cleaner than installing RSAT, then removing it. Plus we wanted to leave the AD extensions on the systems for later use. Since the binaries date back to 2016 even on the “latest” version. Its a safe bet this method is going to work for the forseeable future.

Leave a Reply