Powershell Script to output in CSV Format: ExcDisplayName , Last logon/Activity, TotalItemSize(KB), ItemCount

Posted on 2011-10-18
Last Modified: 2012-05-12

Mailbox Server Name: Exch01.. (Exchange 2007 SP3 Environment)
Domain Name: Contoso.local
DC Name: ContosoDC1

I need a powershell script that outputs in CSV format on mailbox the following info:

DisplayName (i.e Mailbox Name),
Last logon/Activity,
Question by:datacomsmt
    LVL 39

    Expert Comment

    by:Krzysztof Pytko
    Try to run this syntax in EMS

    Get-MailboxStatistics | fl DisplayName,LastLogonTime,TotalItemSize,ItemCount | Export-CSV c:\output.csv

    LVL 14

    Accepted Solution

    Sometime like get-mailbox | get-mailboxstatistics | ft (the values you want to view separated by ,) | export-Csv (filename)

    I'm on my phone I'm sure someone else can verify the exact attributes to search for.
    LVL 3

    Expert Comment

    This is what I use. It outputs a txt file, but it opens with Excel easily.
    It only returns connected mailboxes.

    Get-ExchangeServer 'ServerPrefix*' |? {$_.serverrole -match "Mailbox"} | Get-MailboxStatistics | Where-Object { $_.DisconnectDate -eq $null } | Format-Table -AutoSize Database, @{label=”User”;expression={$_.DisplayName}}, @{label="Last Logged On By";expression={$_.LastLoggedOnUserAccount}}, @{label="Item Count";expression={$_.ItemCount}}, @{expression={$_.totalitemsize.value.ToMB()};label="Size (MB)"}, @{label=”Storage Limit”;expression={$_.StorageLimitStatus}}, @{label="Last Logon";expression={$_.LastLogonTime}}, @{label="Last Logoff";expression={$_.LastLogoffTime}} | Out-File  filename.txt -width 375



    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
    In this video we show how to create a Distribution Group in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >>…
    This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now