Solved

Powershell script to display Exchange 2003 Mailboxes by Location

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Microsoft Windows Server Update Service (WSUS) is free for everyone, but it lacks of some desirable features like send an e-mail to the administrator with the status of all computers on the WSUS server. This article is based on my PowerShell script …
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

776 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