How can I use Active Directory commands in a Powershell script?


They are available in Server 2008 R2 as an installable feature. I believe Server 2008 R2 is the only platform that supports that.

| improve this answer | |
  • No, thats not true. I just want to import the AD module within my freaking script :) – Jonathan Rioux Aug 16 '10 at 17:15
  • 1
    I am rather certain this is correct. You can look into the Quest add-ins that add similar features but the true get-aduser is 08R2 only right now. technet.microsoft.com/en-us/magazine/ee914610.aspx andersrask.spoint.me/2010/07/28/… – David Remy Aug 16 '10 at 18:26
  • If the module is available, you can import it into your script with import-module $modulename – SysAdmin1138 Aug 16 '10 at 20:55
  • One of the complications with the Get-ADUser cmdlet is that it depends on Active Directory Web Services being available. My guess is that many domains will not have this available (I know ours does not). – Shannon Wagner Feb 17 '12 at 15:38

I would highly recommend installing Quest Software's free set of Active Directory cmdlets.

With this, you get access to commands like Get-QADUser and Get-QADObject which probably provide all the functionality you will need, without the dependency on Active Directory Web Services that Get-ADUser has.

Another option would be to use PowerShell's ability to instantiate .NET objects and use the DirectoryServices namespace of the .NET Framework. But unless you need something that is not available via the Quest tools, using .NET is probably more complicated than you need.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.