Learn about Windows PowerShell
Summary: Use the Filter parameter in the Active Directory module.
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?
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"'
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.
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 :)
@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.
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. :)
...and for this I am still the student Oh wise and wonderful Master of Scripting :)
thanks for shearing it....