Link to home
Start Free TrialLog in
Avatar of datacomsmt
datacomsmtFlag for Australia

asked on

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

HI

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,
TotalItemSize(KB),
ItemCount
Avatar of Krzysztof Pytko
Krzysztof Pytko
Flag of Poland image

Try to run this syntax in EMS

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

Regards,
Krzysztof
ASKER CERTIFIED SOLUTION
Avatar of Radweld
Radweld
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
   

 [  

I am all late with this but is there a way to run this same powershell but ONLY look at certain databases? Reason being we have 3 exchange databases and I am only interested in two of them. The third one is a former Employee database and I dont need to see 5000 unnecessary details.