Monday, February 4, 2013

List All Windows Systems in AD

If you dont have the capabilities to download and install Quest Active Roles Powershell snapin then you can still get a list of Windows systems in the AD using native powershell commands!!

$searcher=new-object system.directoryservices.directorysearcher
$searcher.filter="objectcategory=computer"
$searcher.sort.propertyname="name"
$results=$searcher.findall()
write-host "found" $results.count "computers = PCs & Servers"
$results | select @{name="Name";Expression={$_.properties.name}} > c:\output\AllWindowsSystems.txt

This uses the directory searcher to connect to the AD, it provides a flat file that can be used to report on each system, all you have to do is edit the output text file and remove the title and this file can be used as an input array.

No comments:

Post a Comment