Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

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

share|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
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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