locked
filter mailboxes domain wise RRS feed

  • Question

  • we are on exchange 2007 sp1

    we have about 20 accepted domains.

    i need to get a complete list of mailboxes filtered domain wise. can someone help me with a command.

    I am Looking for an out of

    Display Name:

    Database Name:

    Domain: for example @abc.com

    or a list of all users whose primary SMTP are "username"@abc.com

    kindly help.

    cheers philip

    Tuesday, September 25, 2012 8:17 AM

Answers

  • On Tue, 25 Sep 2012 08:17:00 +0000, sphilip14 wrote:
     
    >
    >
    >we are on exchange 2007 sp1
    >
    >we have about 20 accepted domains.
    >
    >i need to get a complete list of mailboxes filtered domain wise. can someone help me with a command.
    >
    >I am Looking for an out of
    >
    >Display Name:
    >
    >Database Name:
    >
    >Domain: for example @abc.com
     
    Try this:
     
    $fname = 'output.csv'
    "DisplayName,Database,Domain" | out-file $fname
    $domains = get-accepteddomain | foreach {$_.DomainName.ToString()}
    get-mailbox | foreach {
    foreach ($a in $_.EmailAddresses) {
    if ( $a.prefixstring -eq "smtp" -and $domains -contains
    ($a.smtpaddress.ToString().split('@')[1]) )
    {
    $d = $a.smtpaddress.split('@')[1]
    "$($_.displayname),$($_.database),$d" | out-file -file $fname
    -append
    }
    }
    }
     
    There'll be duplicates if people have multiple e-mail addresses in any
    of the accepted domains.
     
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP
     

    --- Rich Matheisen MCSE+I, Exchange MVP
    • Marked as answer by Zi Feng Wednesday, October 3, 2012 4:15 AM
    Tuesday, September 25, 2012 8:42 PM
  • Hi

    One command you can try

    Get-Mailbox -ResultSize Unlimited | Select DisplayName,Database,@{Name='Domain'; Expression={[String]::join(";",($_.PrimarySmtpAddress.domain))}}

    Hope that helps

    Cheers


    Zi Feng

    TechNet Community Support

    • Marked as answer by Zi Feng Wednesday, October 3, 2012 4:15 AM
    Wednesday, September 26, 2012 9:29 AM

All replies

  • Hi,

    Did you get a chance to look at below thread ?

    http://www.powershellcommunity.org/Forums/tabid/54/aft/4008/Default.aspx

    Thanks

    Saleesh


    If answer is helpful, please hit the green arrow on the left, or mark as answer.

    Tuesday, September 25, 2012 4:59 PM
  • On Tue, 25 Sep 2012 08:17:00 +0000, sphilip14 wrote:
     
    >
    >
    >we are on exchange 2007 sp1
    >
    >we have about 20 accepted domains.
    >
    >i need to get a complete list of mailboxes filtered domain wise. can someone help me with a command.
    >
    >I am Looking for an out of
    >
    >Display Name:
    >
    >Database Name:
    >
    >Domain: for example @abc.com
     
    Try this:
     
    $fname = 'output.csv'
    "DisplayName,Database,Domain" | out-file $fname
    $domains = get-accepteddomain | foreach {$_.DomainName.ToString()}
    get-mailbox | foreach {
    foreach ($a in $_.EmailAddresses) {
    if ( $a.prefixstring -eq "smtp" -and $domains -contains
    ($a.smtpaddress.ToString().split('@')[1]) )
    {
    $d = $a.smtpaddress.split('@')[1]
    "$($_.displayname),$($_.database),$d" | out-file -file $fname
    -append
    }
    }
    }
     
    There'll be duplicates if people have multiple e-mail addresses in any
    of the accepted domains.
     
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP
     

    --- Rich Matheisen MCSE+I, Exchange MVP
    • Marked as answer by Zi Feng Wednesday, October 3, 2012 4:15 AM
    Tuesday, September 25, 2012 8:42 PM
  • Hi

    One command you can try

    Get-Mailbox -ResultSize Unlimited | Select DisplayName,Database,@{Name='Domain'; Expression={[String]::join(";",($_.PrimarySmtpAddress.domain))}}

    Hope that helps

    Cheers


    Zi Feng

    TechNet Community Support

    • Marked as answer by Zi Feng Wednesday, October 3, 2012 4:15 AM
    Wednesday, September 26, 2012 9:29 AM