1

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

1

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

  • 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
1

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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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