locked
Powershell to find user data RRS feed

  • Question

  • Hi

    We are running Exchange 2007 SP3 and Exchange 2010 SP1 in our environment. I have been given a list of users (about 50) in a CSV file and I need to export the data to another CSV file showing:

    i. Their mailbox database
    ii. Their mailbox server

    I'm not sure how I can do this?

    Also, if possible I would like to export a the CAS server that they are connected to (for 2010 users). Does anyone know how I coudl do this?

    Sunday, February 19, 2012 8:40 PM

Answers

  • Hi

    At First, you CSV should be set as the format like

    Name

    aaaa

    bbbb

    cccc

    For one command to run:

    Import-CSV <PathOfCSV> | ForEach{Get-Mailbox -Identity $_.Name | Select Name,ServerName,Database} | Export-CSV <PathOfCSV>

    Cheers

    Zi Feng


    Zi Feng

    TechNet Community Support

    • Proposed as answer by Jamestechman Tuesday, February 21, 2012 3:08 PM
    • Marked as answer by Zi FengModerator Monday, February 27, 2012 2:04 AM
    Tuesday, February 21, 2012 7:59 AM
    Moderator

All replies

  • That's relatively easy to get provided you have access to the Exchange cmdlets for get-mailbox and get-mailboxdatabase.

    If your Exchange 2010 environment is using DAGs what server their mailbox is on can be ambigous - in can exist on multiple servers, and which one it's on right now can be different tomorrow.

    Same for the CAS servers if you've got multiple CAS servers behind a load balancer.  Get-logonstatistics can show you which CAS server their Outlook is connected to right now, but that might be different the next time they log on.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    Sunday, February 19, 2012 9:17 PM
  • Hello

    Sure, we are just after the info at the moment.

    I have access to get-mailbox and get-mailboxdatabase cmdlets.

    Do you know how I would actually run this though in one command? Assuming the list of users is in a file named Users.csv

    Sunday, February 19, 2012 9:34 PM
  • I'm doubtful that you could do that all in one command line.

    They architecture changed between Exchange 2007 and 2010.  In 2007 databases are a property of the server. In 2010 the server is a property of the database.

    I could sort it out if I was sitting at an EMS shell with both 2007 and 2010 servers behind it, but I'm not, and I'm not good enough to spit out exactly what you'll need off the top of my head.


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    Sunday, February 19, 2012 10:19 PM
  • Hi

    At First, you CSV should be set as the format like

    Name

    aaaa

    bbbb

    cccc

    For one command to run:

    Import-CSV <PathOfCSV> | ForEach{Get-Mailbox -Identity $_.Name | Select Name,ServerName,Database} | Export-CSV <PathOfCSV>

    Cheers

    Zi Feng


    Zi Feng

    TechNet Community Support

    • Proposed as answer by Jamestechman Tuesday, February 21, 2012 3:08 PM
    • Marked as answer by Zi FengModerator Monday, February 27, 2012 2:04 AM
    Tuesday, February 21, 2012 7:59 AM
    Moderator