KB ID 0001405
Problem
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
OR
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“
Create a Mailbox Database
New-MailboxDatabase -Name Database-Name -EdbFilePath X:\Folder\Database\Database-Name.edb -LogFolderPath X:\Folder\Log-Folder\
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
Users and Groups
Exchange Create a Distribution Group
New-DistributionGroup -Name “DG-All-Users” -Type “Security”
Exchange Add All Users (In an OU) to a Distribution Group
Get-Mailbox -OrganizationalUnit “cn=users,dc=petenetlive,dc=com” -resultsize unlimited|ForEach-Object { Add-DistributionGroupMember -Identity “DG-All-Users” -Member $_ }
Related Articles, References, Credits, or External Links
NA