Microsoft Exchange Server 2016 shell commands that can be good to know

List all mailbox databases in the organisation

List all mailbox databases with paths
Get-MailboxDatabase | fl Name,EdbFilePath,LogFolderPath

List all mailbox databases with informations about them
Get-MailboxDatabase -status | fl *

Show mailbox databases and the backup status
Get-MailboxDatabase -status | ft server,name,LastFullBackup,LastIncrementalBackup,DatabaseSize

Change name of a mailbox database
Set-MailboxDatabase “Mailbox Database 1721414988” -Name “DB02”

Change database and log ptah of a mailbox database
Move-DatabasePath DB02 -EdbFilePath M:\DB02\DB02.edb -LogFolderPath N:\DB02

Change the queue and queue log path
Create the directories, example:

  • mkdir “Q:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\data\Queue”
  • mkdir “R:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\data\Queue”

Give “Network service” full control of this directories.
Open the file %ExchangeInstallPath%Bin\EdgeTransport.exe.config in notepad
Change the paths on the rows looks like below

  • <add key=”QueueDatabasePath” value=”Q:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\data\Queue” />
  • <add key=”QueueDatabaseLoggingPath” value=”R:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\data\Queue” />

After this changes you need to restart the transport service

Move system mailboxes to a new mailbox database
Get-Mailbox -Arbitration | New-MoveRequest -TargetDatabase DB02

Clean up completed move requests
Get-MoveRequest -MoveStatus Completed | Remove-MoveRequest

Show all e-mail accounts/recipients with e-mail addresses
Get-Recipient | Select Name, EmailAddresses

Show all mailboxes in a mailbox database
Get-Mailbox -Database “Mailbox Database”

Show the mail queue

How to make a unattended uninstallation of Microsoft Exchange Server 2016?

I was running the uninstallation of a Microsoft Exchange Server 2016 and the server crash and reboot.

After the reboot i try to start the uninstallation again and only got “An incomplete installation was detected. Run setup to complete Exchange Installation.”

When try to run the setup from the installation DVD/ISO it not starts so i search for help and find out that i could start a unattended uninstallation by starting a Command prompt as adminsitrator and go to where the setup.exe file is on the DVD and then run the command:

  • Setup.exe /mode:Uninstall /IAcceptExchangeServerLicenseTerms

Then it start running “Welcome to Microsoft Exchange Server 2016 Unattended Setup”.

How to force removal of Exchange Server Mailbox database?

I have got some problems with one of my mailbox databases on my Microsoft Exchange Server 2016 server, its has been corrupt for some months without me could repair it and now it was time to remove the whole Exchange server from the organisation.

So i tested everything and search for some help and after some time i find out that you can force the removla of a exchange server mailbox database from the ADSI Edit tool.

Practical you telling the AD to remove the knowledge of the database with this hack.

  • Start with log on to the Domain Controller
  • From the start menu select run and enter adsiedit.msc and press run button.
  • In the tool, right-click ADSI Edit and select Connect to.
  • In the “Connection Settings”-dialog under “Select a well known Naming Context” select Configuration and click OK.
  • Navigate to CN=Configuration [domain] → CN=Services → CN=Microsoft Exchange → CN=[organization] → CN=Administrative Groups → CN=Databases
  • Identify the Mailbox Database containers that you like to remove and delete them.

Make sure that you are not deleting working mailboxes from the list, if you delete any by mistake you will have to delete & recreate the entire user using Active Directory Users & Computers.