Solved

Powershell script to display Exchange 2003 Mailboxes by Location

Posted on 2010-08-17
5
648 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 71

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

737 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