i was unable to get the Domainname when i ran the powershell script in exchange 2007

Murali used Ask the Experts™
We are using Exc2007 servers and in my organizatio we have one primary domain controllers and two child domain controllers as below.
2) ad.dc.domain.com
3)ad1.dc.domain.com All domain users have mailboxes. Now i would like to run the powershell script to get the info like userdisplay name and database name and storage group name and domainname as well. I ran below script

Get-mailbox -Organizationunit 'name' | get-mailboxstatistics | select-object displayname, servername, databasename, storagegroupname i was getting this info. But i was unable to get the domain name as user belongs to which domain  (1dc.domain.com 2) ad.dc.domain.com 3)ad1.dc.domain.com. Can anyone help on this.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
PowerShell Developer
Top Expert 2010

You mean you have configured each a child domains? Not just DCs within the same domain?

Anyway, you can do it like this:

Get-Mailbox -Organizationunit 'name' | ForEach-Object {
  $Domain = $_.Identity.DomainId.ToString()
  Get-MailboxStatistics | Select-Object DisplayName, ServerName, DatabaseName, StorageGroupName,
    @{n='Domain';e={ $Domain }}

The domain name isn't really part of the return from Get-MailboxStatistics, however, we can add fields (from Get-Mailbox) to the output with the custom property (@{name='Name';expression={ "Thing to figure out the value" }}) as above.


Chris DentPowerShell Developer
Top Expert 2010

This question has been classified as abandoned and is being closed as part of the Cleanup Program.  See my comment at the end of the question for more details.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial