Sample script that searches Active Directory for all computers running Windows XP. The operatingSystemVersion attribute is not replicated to the Global Catalog, meaning you cannot connect to a Global Catalog server and search across the forest for computers with a specified operating system. This attribute is automatically added to the computer account object when you join the computer to the domain.

PowerShell
Edit|Remove
$strFilter = "(&(objectCategory=Computer)(operatingSystemVersion=5.1 (2600)))"

$objDomain = New-Object System.DirectoryServices.DirectoryEntry

$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = $objDomain
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter

$colProplist = "name"
foreach ($i in $colPropList){$objSearcher.PropertiesToLoad.Add($i)}

$colResults = $objSearcher.FindAll()

foreach ($objResult in $colResults)
    {$objItem = $objResult.Properties; $objItem.name}