Exchange Shell

Description Command
Import AD Commands Import-Module Activedirectory
Get Mailbox Sizes Get-MailboxStatistics -server "SERVEREX" | Select DisplayName, ItemCount, TotalItemSize | Sort-Object TotalItemSize -Descending | Export-CSV C:\MBSizes.csv
Get Mailbox Sizes (alt) get-mailbox –resultsize unlimited | get-mailboxstatistics | select-object DisplayName,TotalItemSize,StorageLimitStatus,LastLogonTime > mailboxsize.txt
Export Mailboxes (2010) New-MailboxExportRequest -mailbox "Mailbox Name" -filepath \\serverex\PST\
See Mailbox Export Progress Get-MailboxExportRequest | Get-MailboxExportRequestStatistics
Clear Completed Mailbox Exports Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest
Get ALL email addresses Get-Recipient | Select Name -ExpandProperty EmailAddresses | Select Name, SmtpAddress | Export-csv c:\AllEmailAddress.csv
Change or add folder permissions Add-MailboxFolderPermission -Identity User1:\Calendar -User "UserWhoWantsAccess" -AccessRights Editor
Purge disconnected mailboxes Remove-StoreMailbox –database “MyDatabaseName” –identity “Joe Blogs” –MailboxState Disabled
Exclude database from auto selection during mailbox creation Set-MailboxDatabase -Identity "Mailbox Database" -IsExcludedFromProvisioning $True
Check Database ‘whitespace’ Get-MailboxDatabase –Status | ft name,databasesize,availablenewmailboxspace -auto
Compact / Defrag a dismounted database (Optional temp location to build the new database.) eseutil /d MB-HO-01.edb /t\\testserver\defrag\temp.edb
List mailboxes where the forwarding address is not null Get-Mailbox | Where {$_.ForwardingAddress -ne $null} | Select Name, PrimarySMTPAddress, ForwardingAddress, DeliverToMailboxAndForward
Find where an email address ends up Get-Recipient
Get-Recipient "*@domain*"
Export membership of a dynamic distribution group $DynamicGroup = Get-DynamicDistributionGroup "Team Manchester"Get-Recipient -RecipientPreviewFilter $DynamicGroup.RecipientFilter -OrganizationalUnit $DynamicGroup.RecipientContainer | select Displayname,PrimarySmtpAddress > c:\members-of-dynamic-group.txt
List Shared Mailboxes get-mailbox | Where {$_.RecipientTypeDetails -eq "SharedMailbox"} | Select Name




Mailbox Sizes

New-MailboxExportRequest -Mailbox Stephen.King-FilePath \\SERVER2012FS\pst-temp\stephen.king.pst

Get-MailboxExportRequest | Get-MailboxExportRequestStatistics

Get-MailboxExportRequest | where {$_.status -eq "Completed"} | Remove-MailboxExportRequest

Set-Mailbox -Identity "Stephen King" -RetainDeletedItemsFor 0

Remove-Mailbox -Identity contoso\john -Permanent

Remove-StoreMailbox -Database "Archive - Manchester" -Identity "Stephen King" -MailboxState Disabled


Exchange Retention Policy Commands

Get-Retentionpolicy “Test Policy” | fl Get-Mailbox | ft name,retentionpolicy -auto
Enable-Mailbox “Stephen King” -Archive Set-MailboxServer SERVER2012EX –ManagedFolderWorkCycle 1
Start-ManagedFolderAssistant Stephen.King