PowerTip: Find List of Users in Active Directory

PowerTip: Find List of Users in Active Directory

  • Comments 9
  • Likes

Summary: Use the Filter parameter in the Active Directory module.

Hey, Scripting Guy! Question I was playing with the Active Directory cmdlets and noticed that they seem to need the Distinguished Name.
           Is there any way to find users instead of supplying this very explicit object each time?

Hey, Scripting Guy! Answer Use the –Filter parameter to pull the information. For example, to find all users with the last name Smith,
           specify the Surname attribute with the –Filter parameter:

GET-ADUser –filter 'Surname –eq "Smith"' 

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • That's one of my favorites, combine this with another PowerShell command or two and that ability to modify large groups of users is easy.

  • @Anthony

    Before PowerShell I used to play with the Query command in Active Directory Users and Computers. It worked well too. But with PowerShell and simple parameters it made a lot more sense to me :)

    Cheers!
    Sean

  • @Sean Kearney (Honorary Scripting Guy) For more complex things, I still use the LDAP query syntax. For one thing, they are easy to port from one language to another, and for another, I have already written them and they just need minor tweaking to make them work in PowerShell. But for simple things, -FIlter rocks.

  • @Sean @Ed

    Agreed, hard to beat LDAP, but get-adgroupmember and get-aduser combined with simple filters seems to catch 95% of what I need to do these days. Perhaps they've made me lazy though. :)

  • @Ed

    ...and for this I am still the student Oh wise and wonderful Master of Scripting :)

    Sean

  • thank you

  • thank you

  • thanks for shearing it....
    http://ghazipurkhabar.co.in/