| pid | 1023 |
|---|---|
| author | Paul Brice |
| title | Get Exchange2003 Servers |
| date | 2009-04-14 11:31:45 -0700 |
| format | posh |
| parent | 1022 |
Gathers all Exchange 2003 server objects from the W2003 Active Directory Configuration container using ADSI and LDAP. Servers are populated into an [Array] for further use.
[Array]$ExchSrvs = @("")
[String]$StrFilter = "(objectCategory=msExchExchangeServer)"
$objRootDSE = [ADSI]"LDAP://RootDSE"
[String]$strContainer = $objRootDSE.configurationNamingContext
$objSearcher = New-Object System.DirectoryServices.DirectorySearcher
$objSearcher.SearchRoot = New-object System.DirectoryServices.DirectoryEntry("LDAP://$strContainer")
$objSearcher.PageSize = 1000
$objSearcher.Filter = $strFilter
$objSearcher.SearchScope = "Subtree"
$colResults = $objSearcher.FindAll()
ForEach($objResult in $colResults)
{
[String]$Server = $objResult.Properties.name
$ExchSrvs += $Server
}
$ExchSrvs.Count