locked
Powershell Script to query mailboxes RRS feed

  • Question

  • G'day all!

    I am after a Powershell script (Exchange 2003) that will deliver a list of mailboxes (piped to a file) from certain servers (server names all start with a fixed set of characters, e.g. "XYZ") where the last logon time is prior to a certain date.  The list needs to include the name of the mailbox, the owner(s) and the last logon time.

    Tuesday, July 26, 2011 4:29 AM

All replies

  •  

    Since i dont have Exchange 2003 server handy, i could not get you the exact command, however i could give you an powershell script which will export the mailboxes from Exchange 2003 server to CSV file.

    Try to user -filter/ or "Where" command and filter the mailboxes as your requirement

    ################################################################################################

    $day = Get-Date -UFormat "%Y%m%d"

    # Gets data through WMI from specified Exchange mailbox servers

    $computers = "server1","server2","Server3"

    foreach ($computer in $computers) {

    Get-Wmiobject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer $computer   | sort-object -desc LastLogonTime | select-object MailboxDisplayName,StorageGroupName,StoreName,Size,LastLogonTime | Export-Csv -Path $computer-$day.csv

    }

    #################################################################################


    >>:::.... if you find it useful, mark this as answer ...:::<< Thanks & Regards, Sandheep [...:::""I can't do it" never yet accomplished anything; "I will try" has performed wonders ":::...]
    Tuesday, July 26, 2011 4:57 AM