Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Finding Exchange 2003 Servers in AD

Reply
 
Old 06-24-2008   #1 (permalink)
jmedd


 
 

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 SpecsSystem Spec
Old 06-24-2008   #2 (permalink)
Shay Levi


 
 

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 SpecsSystem Spec
Old 06-25-2008   #3 (permalink)
jmedd


 
 

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 SpecsSystem Spec
Reply

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46