Sample script that searches Active directory for all the users who work in the state of Washington. The st attribute is replicated to the Global Catalog. This means you can connect to a Global Catalog server and search across the forest for users from a particular state. Note that this attribute is not automatically populated any time you create a user account.

PowerShell
Edit|Remove
$strFilter = "(&(objectCategory=User)(st=WA))"

$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}