Solved

Powershell script to display Exchange 2003 Mailboxes by Location

Posted on 2010-08-17
5
639 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

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 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

14 Experts available now in Live!

Get 1:1 Help Now