move on-premise mailboxHow to move on-premise mailbox using Exchange Administration Console

Exchange PowerShell is built on Windows PowerShell technology and provides a powerful command-line interface that enables the automation of all administrative tasks relating to microsoft Exchange. Learning PowerShell and Exchange PowerShell can be difficult and confusing, here are some tips and example commands that really helped me along the way. Understanding Exchange PowerShell fundamentals can go a long way in helping administer, troubleshoot and perform exchange tasks more efficiently.

Exchange Powershell Cmdlet Format

All cmdlets will consist of a verb and a noun, separated with a hyphen (the “verb-noun” rule). For example, some of the verbs include:

  • Get — Command to get something
  • Set — Command to set or define something
  • Start — Command to run something
  • Stop — Command to stop something that is running
  • New — Command o create something 


The Get-command is useful to find and list a specific set of Exchange PowerShell commands.  Placing a word in inverted commas behind the command will find commands that include that specific word.

Get-command -Name *Mail* or just Get-Command *Mail  will return all cmdlets that contain Mail

Excchange Powershell get command

Get-Help Command

The Get-Help command is another command which I have used a lot to remind me of the functionality of the Exchange PowerShell command. If you come across a new Exchange PowerShell cmdlet and don’t know what it will do then use this command and the information about the command will be shown to you. 

For example, you don’t know what Get-Mailbox means. To find out more, type
Get-Help Get-Mailbox
This will then display information about this CMDLET. I would recommend that you run this command on all of your commands that you are running for the first time.  It can be very helpful.

Special Variable $_

We see the $_ sign in a lot of cmdlets. This is known as a Special Variable.
The $_ represents the objects being passed from one cmdlet to another cmdlet in the pipeline. The $_ variable is automatically initiated by the shell and is bound to the current pipeline object. You can access the properties of the object assigned to the $_ variable as you would any other object.
The following example shows how you can view the Name property of each mailbox object
that is passed through the pipeline:  

For example, this one lists all running services on an Exchange server
Get-Service | where {$_.Status -eq “Running”} 

On the left side of the pipe line gets all objects that are services, the right side of the pipelines grabs these objects and filters them bu the Running State.

Exchange Powershell get service

Tilde Character

The tilde character (~) represents the shortcut to s specified root directory.  This example command is using a tilde character as a shortcut to the current user’s home folder.

Use it as a shortcut:
PS> FileName “~\My Documents”

You can change what the Tilde character resolves to by using the resolve path command.  This changes the Tilde character to C:\Windows
PS C:\> Resolve-Path -Path C:\Windows

Filter Results

The -FILTER and –LIKE commands are often used together. This will filter the information in Double quotes and look for data matching info in Single quotes 
Again, easy when explained with an example:
Get-Mailbox –RESULTSIZE UNLIMITED -FILTER “Displayname –Like ‘Brown, Johnathon’”
So, this Exchange PowerShell cmdlet is going to get mailbox information where the result will be unlimited and will filter information to ensure only the one with Displayname ‘Brown, Johnathon’ is returned.

Quotation marks in Exchange PowerShell

In Exchange PowerShell, you use single quotation marks ( ‘ ) or double quotation marks ( ” ) to enclose parameter values that contain spaces. For example, the following commands behave the same:

Get-ReceiveConnector -Identity “MyCompany Receive Connector”

Access the Event Log

You can access the event log from the Exchange Management Shell. 

For example all exchange events log in list format.
Get-EventLog Application | Format-List

To retrieve all Exchange-related events, run:

Get-EventLog Application | Where { $_.Source -Ilike “*Exchange*” }


A pipe “|” passes data from one cmdlet to another. When using a pipeline in PowerShell every object that is returned from the first cmdlet is passed on to the right side of the pipe. It is important to notice that in PowerShell what is transferred through the pipe are objects and not characters: 

Get-Service | ConvertTo-Csv | Out-File “C:\temp\Services.csv”  

This example performs 3 tasks but each task is passed through Pipes.  Get list of services -> Convert to CSV file -> save to location

Log Commands

The Exchange Management Shell can log all the Exchange-related commands that modify objects in some way. Exchange-related command activity is logged to the PowerShell event log. To enable Exchange-related command logging, run the following command:
Set-ItemProperty HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.Exchange.Management.PowerShell.Admin -Name LogpipelineExecutionDetails -value 1

Get User Command

Get-User | Format-Table Name, Title

The Get-User command retrieves a list of all Active Directory users. The pipe symbol ( | ) redirects the command’s output into a secondary command. In this case, the secondary command tells Exchange to format the output as a table and to display the user’s name and title. Name and Title are names of Active Directory attributes; you can substitute other attribute names or add attributes.

Move a mailbox

Exchange PowerShell also allows you to move a mailbox to a different database. The following command moves a user named JBrown to a mailbox database named Users:  
Get-Mailbox “JBrown” | Move-Mailbox –TargetDatabase “Users”

This Exchange PowerShell command begins with the Get-Mailbox command, which specifies JBrown in this instance. But you could use a variation of this command to retrieve multiple mailboxes. Next, the command pipes the retrieved mailbox into the Move-Mailbox command. Notice that you’re required to provide the Move-Mailbox command with the name of the target mailbox database.

Stop Command Executing

This one is not exactly a PowerShell cmdlet tip. This works in command prompt too. CTRL+C will hard-break command in the Exchange Management Shell. If a command is taking too long to run or you want to cancel an operation quickly, press CTRL+C to stop execution.

Check Mailbox Database Status

When some or a group of users complain that they cannot access their mailbox, check the mounted status of all mailbox databases. Type:
Get-MailboxDatabase -Status | Format-Table Name, Server, Mounted

Enable or Disable OWA Access

Control which features are available to Outlook Web Access users by using the Set-OwaVirtualDirectory cmdlet. Type:
Set-OwaVirtualDirectory “OWA (Default Web Site)” -ContactsEnabled $True -ChangePasswordEnabled $True
This one will disable Outlook web access for the user

Quickly connect to Exchange Online PowerShell

The above Exchange PowerShell commands are used to perform tasks with Microsoft Exchange Server. If you’re going to be working with Office 365, this is a different story and you will need to connect to your tenancy before running Exchange Online PowerShell Commands. Finding the commands to connect to Exchange online can take time, so it’s a good idea to set up your computer with the appropriate PowerShell cmdlets to automatically connect.

FunctionConnect-EXOnline{$credentials= Get-Credential-Credential Write-Output"Getting the Exchange Online cmdlets"$Session= New-PSSession-ConnectionUri `-ConfigurationNameMicrosoft.Exchange-Credential$credentials`-AuthenticationBasic-AllowRedirectionImport-PSSession$Session}

Leave a Reply

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