Exchange: PowerShell Commands

KB ID 0001405


This might seem like an odd title for an article here at PNL? But I’m going to use this page as a place to put all the commands I’m sick of Googling for, and/or working out every time I do an Exchange job.

So as with all the posts here, it’s here for my benefit, and if anyone else gets something from it great!

Exchange General

Change Exchange Licence Code

Set-ExchangeServer -Identity Server-Name -ProductKey 12345-12345-12345-12345-12345

Exchange Mailboxes

How Many Mailboxes Per Database?

Get-Mailbox | Group-Object -Property:Database | Select-Object Name,Count | Sort-Object Name | Format-Table -Auto


Exchange Mailbox Migrations

Migrate a Single Mailbox

New-MoveRequest -Identity “Fred Bloggs” -TargetDatabase “Destination-DB” -BatchName “Fred Bloggs” -BadItemLimit “200” -AcceptLargeDataLoss

Migrate ALL Mailboxes in one Database to Another

Get-Mailbox -Database “Source-DB” ” -ResultSize Unlimited | New-MoveRequest -TargetDatabase “Destination-DB

Display Mailbox Migration Progress

Get-moverequest | get-moverequeststatistics


Get-moverequest -MoveStatus InProgress

Get-moverequest -MoveStatus Failed

Get-moverequest -MoveStatus Queued

Remove Mailbox Move Requests

Get-MoveRequest -MoveStatus Completed | Remove-MoveRequest

Exchange Databases

List All Mailboxes in a Database

Get-Mailbox -Database “Database Name

Show Database (and Log File) Locations

Get-MailboxDatabase -Status | select EdbFilePath Get-MailboxDatabase -Status | select LogFolderPath

Move a Database (and Log Files)

Move-DatabasePath -Identity Database-Name -EdbFilePath X:\Folder\Database\Database-Name.edb Move-DatabasePath -Identity Database-Name -LogFolderPath X:\Folder\Log-Folder\

Show Mailbox Database ‘Whitespace’

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


Related Articles, References, Credits, or External Links


Author: PeteLong

Share This Post On

Submit a Comment

Your email address will not be published. Required fields are marked *