Exchange PowerShell Variables

Since the release of Exchange Server 2007 (the first version to include PowerShell) that the Exchange Management Shell (EMS) includes the following three pre-defined variables:

  • $exbin – contains the full path to Exchange’s Bin directory;

  • $exinstall – contains the full path to Exchange’s install folder;

  • $exscripts – contains the full path to the Exchange’s script folder.


In a default installation of Exchange 2016, this is what these variables contain:



These variables are used in different scenarios such as some scripts provided by Microsoft, and can also be used by administrators to facilitate the management of Exchange. But where are these variables defined? Can we add a couple more?

When we load the EMS, the Exchange.ps1 script located in the Bin directory is run. Within this script we can find these variables defined:

$global:exbin = (get-itemproperty HKLM:\SOFTWARE\Microsoft\ExchangeServer\v15\Setup).MsiInstallPath + "bin\"
$global:exinstall = (get-itemproperty HKLM:\SOFTWARE\Microsoft\ExchangeServer\v15\Setup).MsiInstallPath
$global:exscripts = (get-itemproperty HKLM:\SOFTWARE\Microsoft\ExchangeServer\v15\Setup).MsiInstallPath + "scripts\" 



If, for any reason, you would like to add another variable, you can add it here. For example, to add a variable to your Message Tracking Logs directory you could do something like this:

$global:exmsgtl = "E:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\Logs\MessageTracking\"

About The Author

Leave a Comment

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top