Exchange 2007 Shell Commands

Here are some Exchange 2007 shell commands that you may find useful.

Get client version used to connected to mailbox

This command will list the user name and the client version and export it to a csv file.
Get-MailboxServer | Get-LogonStatistics | Select UserName,ClientName,ClientVersion,LogonTime | Export-Csv -Path c:\ExchangeClientVersions.csv

Get Activesync Devices

This command filters mobile devices that successively synced after the 1st January 2013.
get-mailbox -ResultSize:Unlimited | get-activesyncdevicestatistics -mailbox {$_.identity} | where {$_.LastSuccessSync -gt ‘1/1/2013’} | ft identity,devicetype,deviceuseragent,LastSuccessSync,deviceimei,devicefriendlyname

Get mailbox size in MB

Get-Mailbox | Get-MailboxStatistics |  select-object DisplayName, {$_.TotalItemSize.Value.ToMB()}

Get number of mailboxes

Get-MailboxDatabase | Select Server, StorageGroupName, Name, @{Name=”Number Of Mailboxes”;expression={(Get-Mailbox -Database $_.Identity | Measure-Object).Count}} | Format-Table -AutoSize

Numbers of mailboxes and size

et-MailboxDatabase | Select Server, StorageGroupName, Name, @{Name=”Size (GB)”;Expression={$objitem = (Get-MailboxDatabase $_.Identity); $path = “`\`\” + $objitem.server + “`\” + $objItem.EdbFilePath.DriveName.Remove(1).ToString() + “$”+ $objItem.EdbFilePath.PathName.Remove(0,2); $size = ((Get-ChildItem $path).length)/1048576KB; [math]::round($size, 2)}}, @{Name=”Size (MB)”;Expression={$objitem = (Get-MailboxDatabase $_.Identity); $path = “`\`\” + $objitem.server + “`\” + $objItem.EdbFilePath.DriveName.Remove(1).ToString() + “$”+ $objItem.EdbFilePath.PathName.Remove(0,2); $size = ((Get-ChildItem $path).length)/1024KB; [math]::round($size, 2)}}, @{Name=”No. Of Mbx”;expression={(Get-Mailbox -Database $_.Identity | Measure-Object).Count}} | Format-table -AutoSize

Get mailbox sizes and item count

Get-MailboxStatistics | Sort-Object TotalItemSize –Descending | ft DisplayName,@{ expression={$_.TotalItemSize.Value.ToKB()}},ItemCount

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s