Handy Exchange Management Shell commands

Some Handy Exchange Management Shell commands I frequently use;

  • Enable auditing for all user mailboxes
    Get-Mailbox | Where-Object {$_.RecipientTypeDetails –eq “UserMailbox”} |Set-Mailbox -AuditDelegate Update,SoftDelete,HardDelete,SendAs,Create,FolderBind –Auditenabled $true
  • Get a list of all mailboxes on a Exchange server sorted on size.
    Get-MailboxStatistics -Server SERVERNAME | where {$_.ObjectClass –eq “Mailbox”} | Sort-Object TotalItemSize –Descending | ft @{label=”User”;expression={$_.DisplayName}},@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}},@{label=”Items”;expression={$_.ItemCount}},@{label=”Storage Limit”;expression={$_.StorageLimitStatus}} -auto >>C:\Mailboxsize.txt
  • Delete disconnected mailboxes
    $mailboxes = Get-ExchangeServer | Where-Object {$_.IsMailboxServer –eq $true} | ForEach-Object { Get-MailboxStatistics –Server $_.Name | Where-Object {$_.DisconnectDate –notlike ‘’}} | select displayname, mailboxguid, database

    $mailboxes | ForEach { Remove-Mailbox -Database $_.Database -StoreMailboxIdentity $_.MailboxGuid -confirm:$false }
  • Import PST file into a mailbox into a root folder “Archive”
    New-MailboxImportRequest -FilePath \\uncshare\archive.pst -Mailbox MAILBOXNAME -TargetRootFolder "Archive"
Posted in Exchange 2010 and tagged , , .

Leave a Reply