![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | Finding Exchange 2003 Servers in AD I have a script which queries AD and lists all Exchange 2003 servers. $root= New-Object System.DirectoryServices.DirectoryEntry("LDAP://RootDSE") $cfgNC = [adsi]("LDAP://" + $root.Get("configurationNamingContext")) $search = New-Object System.DirectoryServices.DirectorySearcher($cfgNC) $search.filter = '(objectclass=msExchExchangeServer)' $ExchServer = $search.FindAll() You get the results in the format: LDAP://CN=EXCH1,CN=Servers,CN=First Administrative Group,C........ I need to get them listed as: EXCH1 EXCH2 etc.... So far I can get to CN=EXCH1 CN=EXCH2 with $t = @() foreach ($server in $ExchServer) { $s = ([string]$server.properties.distinguishedname).split(",") $t = $t + $s[0] } but I can't get on from there to what I need and I don't think its a particulalry good way to have done it anyway. So can anyone help me get to where I need? Thanks |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Finding Exchange 2003 Servers in AD $ExchServer | foreach {$_.properties.name} --- Shay Levi $cript Fanatic http://scriptolog.blogspot.com Quote: > I have a script which queries AD and lists all Exchange 2003 servers. > > $root= New-Object > System.DirectoryServices.DirectoryEntry("LDAP://RootDSE") > $cfgNC = [adsi]("LDAP://" + $root.Get("configurationNamingContext")) > $search = New-Object > System.DirectoryServices.DirectorySearcher($cfgNC) > $search.filter = '(objectclass=msExchExchangeServer)' > $ExchServer = $search.FindAll() > You get the results in the format: > > LDAP://CN=EXCH1,CN=Servers,CN=First Administrative Group,C........ > > I need to get them listed as: > > EXCH1 > EXCH2 > etc.... > So far I can get to > > CN=EXCH1 > CN=EXCH2 > with > > $t = @() > > foreach ($server in $ExchServer) > { > $s = ([string]$server.properties.distinguishedname).split(",") > $t = $t + $s[0] > } > but I can't get on from there to what I need and I don't think its a > particulalry good way to have done it anyway. > > So can anyone help me get to where I need? > > Thanks > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Finding Exchange 2003 Servers in AD Brilliant! Thanks indeed. "Shay Levi" wrote: Quote: > > > $ExchServer | foreach {$_.properties.name} > > > --- > Shay Levi > $cript Fanatic > http://scriptolog.blogspot.com > Quote: > > I have a script which queries AD and lists all Exchange 2003 servers. > > > > $root= New-Object > > System.DirectoryServices.DirectoryEntry("LDAP://RootDSE") > > $cfgNC = [adsi]("LDAP://" + $root.Get("configurationNamingContext")) > > $search = New-Object > > System.DirectoryServices.DirectorySearcher($cfgNC) > > $search.filter = '(objectclass=msExchExchangeServer)' > > $ExchServer = $search.FindAll() > > You get the results in the format: > > > > LDAP://CN=EXCH1,CN=Servers,CN=First Administrative Group,C........ > > > > I need to get them listed as: > > > > EXCH1 > > EXCH2 > > etc.... > > So far I can get to > > > > CN=EXCH1 > > CN=EXCH2 > > with > > > > $t = @() > > > > foreach ($server in $ExchServer) > > { > > $s = ([string]$server.properties.distinguishedname).split(",") > > $t = $t + $s[0] > > } > > but I can't get on from there to what I need and I don't think its a > > particulalry good way to have done it anyway. > > > > So can anyone help me get to where I need? > > > > Thanks > > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| diskspace on Exchange Servers | VB Script | |||
| Vista , Micorosoft exchange 2003 & Outlook 2003 | Vista networking & sharing | |||
| Can't Log into Windows 2003 Servers | Vista General | |||
| Exchange 2003: Finding NDR e-mail addresses ? | PowerShell | |||
| vista and 2003 servers | Vista networking & sharing | |||