Disable loading the default drive ‘AD:’ during import-module

All of you who have used the Active Directory (AD) powershell module would have noticed that every time you import the AD module, a default drive ‘AD:’ is also loaded. So when you type the following command:

Import-module ActiveDirectory

You see a progress bar with a message like following:


Basically, during the import-module phase, the AD provider tries to mount a new drive with the name ‘AD’ targeting a Domain Controller (DC). It locates the DC by using the DsGetDcName APIs implemented by the Netlogon service. More information about DC location can be found here.

Upon finding a DC which satisfies certain conditions like the availability of the web service etc, the AD provider tries to mount a new drive targeting that DC. Let’s say that the name of the DC found is MyClosestDC.domain.com, then mounting the drive is similar to typing the following command:

New-PSDrive –Name “AD” –Root “” –PsProvider ActiveDirectory –server “MyClosestDC.domain.com”

Do note that the AD Provider targets the DC in the current machine’s domain. If a DC is not found, as in the case of a machine which is not domain joined, then the default drive is not created and a warning is displayed.

Disable the loading of the default drive

If for some reason, you want to disable the loading of the default drive, then all you have to do is set the value of the environment variable ‘ADPS_LoadDefaultDrive’ to ‘0’. In powershell, this can be achieved by typing the following command:

PS Env:\> $Env:ADPS_LoadDefaultDrive = 0

Now when you import the AD module, the default drive will not be loaded.

This is particularly useful when you are trying to invoke an ADPowershell cmdlet through a command line or vb/powershell script and do not want to load the drive. For example following can be run in a cmd window:

C:\Windows\System32> Powershell.exe –Command $Env:ADPS_LoadDefaultDrive=0; Import-Module ActiveDirectory; Get-ADUser muali -server MyDC;


Please note the above powershell commands only effect the current user session. For a permanent change in the environment variables, use SETX as following:

PS C:\> SETX ADPS_LoadDefaultDrive 0 /M




Mudassir Ali

Software Development Engineer in Test – Active Directory Powershell Team