How to add Powershell – Active Directory module in Windows PE

Sometimes you might want to use the Active Directory module in WinPE.

(I will post one great way to use it later)

First you need to enable powershell support in your bootimage:

If you don’t have the AD-module on your computer install RSAT.

Mount the WIM and copy the following directories to your bootimage:


%windir%\SysWOW64\WindowsPowerShell\v1.0\Modules\ActiveDirectory (x64-image only)



%windir%\Microsoft.NET\assembly\GAC_64\Microsoft.ActiveDirectory.Management (x64-image Only)

%windir%\Microsoft.NET\assembly\GAC_64\Microsoft.ActiveDirectory.Management.Resources (x64-image Only)

%windir%\WinSxS\amd64_microsoft.activedir..anagement.resources_31bf3856ad364e35_6.3.9431.0_en-us_fb186ae865900ae8 (x64-image Only)



To be able to create folders in the WinSxS folder you need to take ownership of the WinSxS-folder and add rights to your user!

When it starts to ask you about all the folders inside, just press “Cancel”.

(only tested on PE4 and PE5)

I copied these files onto a Win 8(.0) Machine that does not have RSAT to try:

As you can see, I do not have RSAT:

Importing the module:

There you go!

You can now use the Active Directory module in PE-powershell!

I have collected all the files here: Files

You can extract these and paste all the folders in to %windir% (you must edit the rights for WinSxS first!)


  1. Hi,

    First, thanks for your tutorial. There is very few informations about winpe and activedirectory on the web, so I’m glad to have found your post.

    I got an error in WinPe when I try to execute import-module ActiveDirectory -verbose
    It says:

    Something strange..

    First, it load AcitveDirectory.psd1
    then, it load the Assembly

    Load ‘Assembly’ from path’.

    then it switch to Loading ‘TypesToProcess’
    and finally it got this message:

    Loading ‘FormatsToProcess’

    Import-module: The ‘assembly ‘Microsoft.ActiveDirectory.Management’ was not loaded because no assembly with that name was found..
    Verify the assembly name and then try again ..

    Very strange because it seems to load it just before.
    Thanks for your help,

  2. It WORKS !!! I Simply forgot to copy the files to the WinSXS directory. You need to verify if the files are really there! This was my mistakes!

    MDT WinPe 5.0 Litetouch X86 now have PowerShell ActiveDirectory module.
    Big big thanks my friend!

  3. Hi there, I would like to subscribe for this
    website to get most up-to-date updates, so where can i do it please help.

  4. Are these files still available for download. I have been trying desperately to make this work (windows 10) and something always seems to be missing. Please help me out.

    1. Hi Blake
      What version of WinPE do you use?
      Could you please explain what kind of errors you see?
      The files were lost during migration to new blog.
      I have updated the files on the post.


  5. Hi, thanks for this!
    I followed the steps above, copying the files manually to the mounted boot.wim. I save, unmount, and create a new boot package (SCCM). When I attempt to run my script though, it fails, with the error:

    “GetADOrganizationalUnit ; The Term ‘GetADOrganizationalUnit is not recognized as the name of a cmdlet, function, script file, or operable program…. etc…

    If I open a PS window and run import-module activedirectory, I get the following response:
    Warning: Error initializing default drive: ‘Unable to find a default server with Active Directory Web Services running.’.
    Did I miss a step?
    I used CMTrace in WinPE as a browser to confirm that all the files and folders are in fact in the boot image.

    1. Not sure if it was a typo in the comment but “GetADOrganizationalUnit” should be “Get-ADOrganizationalUnit” 😀

  6. Hi Christoffer, thanks for this tutorial! It’s exactly what I need to make another one of my scripts work in a SCCM task sequence.
    My script presents the front line tech with a dropdown to select the OU to place the new system in. I’ve been entering a string array of our OUs, but would much rather it was dynamic.
    I have tried copying all the folders and files manually as listed above, that didn’t seem to work, so I used your zip file and copied those to the mounted boot.wim. I successfully saved and unmounted the wim, added it to sccm as a new boot image and applied it to my task sequence.
    Once the drop down comes up, the selection is blank. I dropped to a powershell window in WinPE and tried to run my script manually, but when I try to “import-module activedirectory” I get an error saying Unable to find a default server with active directory web services running.
    If I simply try to run $Items = Get-ADOrganizationalUnit …bunch of parameters here… It tells me the command, cmdlet, etc does not exist.
    I browsed through the WinPE environment, and confirmed that the activedirectory module is included. Is there another step I’m missing?
    thank you!!

    1. Hi James!
      Sorry for the delay!
      Did you take ownership of the WinSXS folder before copying the files into the mounted wim?
      are you using x86 or x64 bootimage?

  7. Hey Christoffer, no worries!

    Yes, I took ownership of WinSXS, and confirmed everything was in place after saving, unmounting, and remounting boot.wim. I am using x64 boot image.
    I also came across another page that suggested adding -server to the Get-ADOranizationalUnit cmdlet, but all that did is tell what I already know, we do not have ADWS running in our network. That was the whole reason I was looking to add the activedirectory module locally 🙂

        1. It seems the problem is not the AD-module.
          This happens because you have not provided any credentials 🙂
          add “-Credential “domain\user”” to your command.

          I get the same error if I do not provide credentials.

          1. I noticed that, but wasn’t sure how to implement it. I just read through how it works, my only concern is having that information in a script on our server.
            Sorry, my “noob” is showing here 😀

          2. Sorry for the delay, had some other fires to fight before I could get back to testing.
            Once I authenticated to our AD, the module, and cmdlets worked perfectly. Thank you very much for your help Christoffer!

  8. I should have considered the issue a bit longer before replying. I could store the plaintext password in a task sequence variable, and pass that to the script. I’ll try that.

Leave a Reply

Your email address will not be published. Required fields are marked *