Find Mailbox Database Sizes

Get-MailboxDatabase -Status | select ServerName,Name,DatabaseSize

List All Active Sync Devices and Export to CSV

Get-ActiveSyncDevice | select-object DeviceModel,FriendlyName,DeviceOS,UserDisplayName | sort-object devicemodel | export-csv C:\list123.csv

Adding BESAdmin Permissions for a Database (Blackberry)

All databases

Get-MailboxDatabase | Add-ADPermission -User "BES_account" -AccessRights ExtendedRight -ExtendedRights Receive-As, ms-Exch-Store-Admin

For a particular database

Get-MailboxDatabase "database_name" | Add-ADPermission -User "BES_account" -AccessRights ExtendedRight -ExtendedRights Receive-As, ms-Exch-Store-Admin

Check Current Permissions (receive-as, send-as or ms-Exch-Store-Admin)

get-adpermission “Mailbox Database 1” | where-object {$_.extendedrights -like ‘receive-as’} | select user,extendedrights
get-adpermission “Mailbox Database 1” | where-object {$_.extendedrights -like ‘send-as’} | select user,extendedrights
get-adpermission “Mailbox Database 1” | where-object {$_.extendedrights -like ‘ms-Exch-Store-Admin’} | select user,extendedrights

Find Mailbox Size and Item Count for One User

Get-MailboxStatistics john.smith | select DisplayName, ItemCount, DeletedItemCount

View number of Calendar Items for a Particular User

Get-Mailbox John.Smith | Get-MailboxFolderStatistics -FolderScope 'Calendar' | select Name, ItemsInFolderAndSubfolders

View number of Items per Folder for a Mailbox and Export to CSV

Get-Mailbox John.Smith | Get-MailboxFolderStatistics | Where {$_.ItemsInFolder -gt 0} | Sort-Object -Property FolderPath -Descending | ft FolderPath,ItemsInFolder -Autosize > JohnMailbox.CSV

Find an Email Address

get-recipient -results unlimited | where {$_.emailaddresses -match "email_address"} | select name,emailaddresses,recipienttype

View White Space in a DB

In Exchnage 2010 Event ID 1221 is not logged when an online defrag runs so to find the amount of white space available in a database you need to run the command below.

Get-MailboxDatabase -Status | Select Servername, Name, AvailableNewMailboxSpace

View hidden System (Arbitration) Mailboxes

Across all Servers

Get-Mailbox -Arbitration | fl Name,DisplayName,ServerName,Database,AdminDisplayVersion

If the commands above return no results, in multi-domain environments, you might need to change the scope to view objects in the entire forest.

Set-ADServerSettings –ViewEntireForest $true

For a Particular Database

Get-mailbox -Database “Mailbox Database 1" –Arbitration -DomainController dc1

Move an Arbitration Mailbox

Get-Mailbox -Arbitration -Database “Mailbox Database 1" | New-MoveRequest -TargetDatabase "Mailbox Database 2"

List User Mailboxes in a Database where the Mailbox is not SoftDeleted (moved), Sort by Size and Export to a Text File

Get-MailboxStatistics -Database "Mailbox Database 1" | Where { $_.DisconnectReason -ne "SoftDeleted" } | Select DisplayName, ItemCount, TotalItemSize | Sort-Object TotalItemSize -Descending >> design.txt


List User Mailboxes in a Database and Sort by Size

Get-MailboxStatistics -Database "Mailbox Database 1" | Select DisplayName, ItemCount, TotalItemSize | Sort-Object TotalItemSize -Descending
Get-Mailbox | Get-MailboxStatistics |  select-object DisplayName, {$_.TotalItemSize.Value.ToMB()} | export-csv -path "c:\exportlist.csv"

Moving Mailboxes

Start a local move request for one user

New-MoveRequest -Identity 'john@lab.com' -TargetDatabase "Mailbox Database 2" -BadItemLimit 20

Start a local move request for many users

Import-CSV "C:\test.csv" | New-MoveRequest -TargetDatabase "Mailbox Database 2"

CSV file format

Identity
“John Smith”
“Jane Smith”
“Bob Jones”

View moves in progress and the percentage

Get-moverequest | get-moverequeststatistics

List All Mailboxes in a ‘Soft Deleted’ State in a Particular Database

When a users mailbox is moved the original mailbox on the source database is put into a soft deleted state. To save on space (rather than waiting for retention periods etc) you can manually deleted it.

Get-MailboxStatistics -Database "Mailbox Database 1" | Where-Object {$_.DisconnectDate -Notlike $NULL} | Format-Table DisplayName, DisconnectDate, DisconnectReason –Wrap

or

Get-MailboxStatistics -Database "Mailbox Database 1" | Where { $_.DisconnectReason -eq "SoftDeleted" } | ft DisplayName, DisconnectReason

Delete a ‘Soft Deleted’ Mailbox.

Remove-StoreMailbox -Database "Mailbox Database 1" -Identity "John Smith" -MailboxState Softdeleted


Delete a ‘Soft Deleted Mailbox Without Prompt

Remove-StoreMailbox -Database "Mailbox Database 1" -Identity "John Smith" -MailboxState Softdeleted -Confirm:$false


Delete all ‘Soft Deleted’ Mailboxes in a Particular Database Without Prompts

$Mailboxes = Get-MailboxStatistics -Database "Mailbox Database 1" | where {$_.DisconnectReason -eq “SoftDeleted”}
$Mailboxes | foreach {Remove-StoreMailbox -Database $_.database -Identity $_.mailboxguid -MailboxState SoftDeleted -Confirm:$False}