≡ Menu

Loading ActiveDirectory PowerShell module without default AD: Drive

One thing that I don’t like while working with ActiveDirectory PowerShell module is, it’s slowness in loading and the crazy progress bar that it shows while creating default AD: drive.

AD-PSDrive-Progressbar

Honestly, I don’t use the AD: ps drive to manage active directory objects as the cmdlets are sufficient enough for most of the operations. Moreover, seeing this progress bar while running the scripts that loads ActiveDirectory module is not nice thing. Also creating the AD: drive is taking quite a bit of time.

I wanted to get rid of all these and just want to import the AD cmdlets alone. While searching for that, I come across a post from Active Directory PowerShell team which helped me. To suppress the progress bar, just below one line before calling the Import-Module.

$Env:ADPS_LoadDefaultDrive = 0

So, that makes your code look like below. With this the import operation will complete fast and you don’t see the progress bar as well.

$Env:ADPS_LoadDefaultDrive = 0            
Import-Module -Name ActiveDirectory            
Get-ADUser -Identity "testuser1"

Hope this helps and happy learning.

Comments on this entry are closed.

  • Conrad September 8, 2015, 3:08 pm

    Do you have you own average figures for the loading times when doing this?
    I get 2.3 seconds versus 0.5 seconds over 4 trial runs.

    (Excluded the First time load after a reboot, which is around 12 seconds for me.)
    PS: $progresspreference=’silentlycontinue’ hides all progress bars