Weekend Scripter: Exchange add-in module

Doctor Scripto

Summary: Mike O’Neill, Microsoft Senior Premier Field Engineer, created an Exchange add-in module.

This is a PowerShell module for Exchange engineers. The module takes into account both on-premises and hybrid deployed Exchange environments.

It is a combination of several other scripts that are either on the internet, or are action items you might need help with in your day-to-day tasks. By combining several lines of code into a single verb-noun cmdlet, it makes repeatable, mundane tasks much easier. In fact, once you have the hang of them, you could delegate them out to other team members with a few minutes of training. Then you would have more time to spend on other aspects of your job, like creating more functions for even further delegation, or combining tasks into a completely automated process.

Current cmdlets in module

Connect-ExchangeServer. Connects to an on-premises Exchange server. You should not log onto servers, but instead should use remote tools or remote connections. This cmdlet allows for quick and easy connections. There is a parameter available to target a specific server, and logic for a prefix parameter if you want to log onto multiple servers simultaneously.

Connect-ExchangeOnline. Connects to an Exchange Online, Office 365 tenant. No need to run several lines of code; just type in this verb-noun cmdlet to log onto an Exchange Online tenant. Included in this cmdlet is the parameter prefix, if you choose to use one. This allows multiple connections in the same PowerShell window.

Disconnect-ExchangeOnline. Disconnects an Exchange Online session.

Get-DatabaseInformation. Obtains database availability group (DAG) database status. This is handy for on-premises Exchange DAG environments. Quickly shows you status of database copies, which ones are healthy or not, and where the active DB is currently hosted.

Start-DAGMaintenanceMode. Puts a DAG node into DAG maintenance mode. With the Exchange product group’s stance of N-1 CU’s when in a hybrid configuration, you need to upgrade Exchange servers often (every 92 days!). This cmdlet puts a server into maintenance mode to be able to patch and/or upgrade your servers cleanly.

Stop-DAGMaintenanceMode. Sets a DAG node out of DAG maintenance mode. Once you are done with the upgrade/patching process, this cmdlet allows you to take a server out of maintenance mode.

Get-DotNETVersion. Acquires the current .NET version on a server (can be used for any computer, not just an Exchange server). This .NET issue occurs often when you upgrade the operating system (versus an application). This cmdlet quickly tells you which version on a machine is currently installed.

Request-CredentialExchangeOnline. Allows you to reset your credentials, in case you “fat finger” them into the prompt.

Request-CredentialExchangeOnPremises. Allows you to reset your onsite credentials to sign into a server if you entered the credentials incorrectly.

Where to find this module

You have two options:

  • If you are running PowerShell 3 or later, you can simply open PowerShell and type Install-Module Exchange_AddIn.  It installs it for you from the PowerShell Gallery.
  • You can easily install the module manually. Download the zip file from the Microsoft Script Center. After you unzip the file, just copy/paste the Exchange_AddIn folder into one of the following locations:
    • %Windir%\System32\WindowsPowerShell\v1.0\Modules
    • %UserProfile%\Documents\WindowsPowerShell\Modules
    • %ProgramFiles%\WindowsPowerShell\Modules


I’m already working on other functions and cmdlets to add in the next version, so stay tuned. I hope you find this Exchange Add-In module helpful. It should assist you in making your day-to-day Exchange tasks within PowerShell quicker and easier. Thank you.

Mike O’Neill

Microsoft Senior PFE, Exchange


Discussion is closed.

Feedback usabilla icon