Ying Li(MVP) at myITforum.com

PowerShell & System Center

October 2008 - Posts

PowerShell one liner to query only servers in AD

Let's say you want to query all the servers in AD, here is a PowerShell one liner to do it, you need to have Quest PowerShell commands for Active Directory installed of course.

Get-QADComputer -sizelimit 0 -OSName '*server*'|export-csv Servers.csv

You could limit the search to a particular OU by using the -searchroot switch.

PowerShell script to find all the .admin users in AD

Let's say every user (in IT) has two accounts - one is their regular user account and the other is their admin account. It could be in the form of xyz.admin(or any other format). How you go about searching your active directory and find all the .admin accounts?

it couldn't be easier than this:

Get-QADUser -ldapFilter '(SamAccountName=*.admin)'|export-csv admins.csv

Of course, you need to have PowerShell Commands for Active Directory from Quest installed first!