Solved

Powershell script to display Exchange 2003 Mailboxes by Location

Posted on 2010-08-17
5
635 Views
Last Modified: 2012-05-10
I am currently running the following script to display the number of mailboxes that exist in the Exchange 2003 environment:
$servers='server01'#, 'server02'
$outfile="c:\scripts\serverbylocation.csv"
 Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer $servers `
| select-object MailboxDisplayName,Size,ServerName,StorageGroupName,StoreName `
| export-csv $outfile -notype

What do I need to do to add in the AD object of  physicaldeliveryofficename?
What I would like to do is have the option to sort my results by location.
0
Comment
Question by:jahhan
  • 2
  • 2
5 Comments
 
LVL 4

Expert Comment

by:Jamie_Wilson
ID: 33457948
Can you just not add physicaldeliveryofficename to your current script ?

e.g.
$servers='server01'#, 'server02'
$outfile="c:\scripts\serverbylocation.csv"
 Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer $servers `
| select-object MailboxDisplayName,Size,ServerName,StorageGroupName,StoreName,physicaldeliveryofficename `
| export-csv $outfile -notype
0
 

Author Comment

by:jahhan
ID: 33458102
I tried that but when I execute the script that column is blank.
0
 
LVL 4

Expert Comment

by:Jamie_Wilson
ID: 33458254
Do you get the same thing if physicaldeliveryofficename is the 1st object?
0
 

Author Comment

by:jahhan
ID: 33458412
Yes and the same outcome.
0
 
LVL 70

Accepted Solution

by:
Chris Dent earned 500 total points
ID: 33462375

WMI doesn't return that field. You have to pull it from AD.

No means to test this, should be this or very close to this.

Chris
$servers='server01'#, 'server02'

$outfile="c:\scripts\serverbylocation.csv"

Get-WmiObject Exchange_Mailbox -Namespace root\MicrosoftExchangeV2 -computer $servers | 
  Select-Object MailboxDisplayName, Size, ServerName, StorageGroupName, StoreName, `
    @{n='Office';e={ 
      $User = (New-Object DirectoryServices.DirectorySearcher("(legacyExchangeDN=$($_.LegacyDN))")).FindOne()
      $User.Properties["physicaldeliveryofficename"][0] }} | 
  Export-Csv $outfile -NoTypeInformation

Open in new window

0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
"Migrate" an SMTP relay receive connector to a new server using info from an old server.
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now