Sample script that searches Active Directory for all the global catalog servers in a forest.

PowerShell
Edit|Remove
$objForest = [System.DirectoryServices.ActiveDirectory.Forest]::GetCurrentForest() 
$objForest.FindAllGlobalCatalogs() | Select-Object Name