PowerTip: Querying Active Directory via PowerShell

PowerTip: Querying Active Directory via PowerShell

  • Comments 7
  • Likes

Summary: Learn how to query Active Directory via Windows PowerShell.

Hey, Scripting Guy! Question Can you name five ways to query Active Directory from within Windows PowerShell?

Hey, Scripting Guy! Answer

  1. Use ADO and perform an LDAP dialect query.
  2. Use ADO and perform an SQL dialect query.
  3. Use the Get-ADObject cmdlet from the Active Directory module.
  4. Use DSQuery.
  5. Use the [ADSISearcher] type accelerator.

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • I like to use Quest's Active Directory commandlets.

  • The ADO bits are excellent.  We don't ever seem to use them.  They can actually create a recordset that can be sorted and bulfk loaded into a database,

    This was a good PowerTip.

  • @Brian Finn lots of people use the Quest AD cmdlets. They were the first ones out there with cmdlets and filled a real need.

    @JRV yes, I still use ADO from time to time. Especially on systems where they have a strong VBScript background, and no .NET experience.

  • There is no Get-ADOObject cmdlet from ActiveDirectory Module. The name of the cmdlet should be:


  • @Yanan Wang you are right. I fat fingered it (Word does not have tab expansion unfortunately). I have updated the article. Thanks for catching this.

  • Can you give a few examples for making ADODB objects in Powershell to connect to AD?

  • How to Query Active Directory Objects