Import Exchange Module PowerShell
Ever started of writing a script in PowerShell ISE and realize you need to Import Exchange Module PowerShell? Your not alone. When you start off writing PowerShell scripts in PowerShell ISE the most common annoying feature is that on an Exchange server it will load all modules as default. However, the exception to this is the Exchange Management PowerShell Snap In. Annoyingly this means running any created scripts in PowerShell ISE when amending, creating or running them results in a failure. The great news is the following blog article shows how you import the applicable Exchange PowerShell module depending on your version of Exchange. Lastly this simple guide will only take seconds to complete and will save you pain of trying to amend large scripts in the built in PowerShell Exchange Shell window.
How To: Import Exchange Module PowerShell
Firstly, of all open PowerShell ISE and run the command as below applicable for your version of Exchange. Lastly, The image below shows once the command has been entered that Exchange commands can the be called as applicable.
Microsoft Exchange Server 2013, 2016 or 2019
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.SnapIn

Microsoft Exchange Server 2010
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Exchange Server 2007 (Microsoft)
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
Now the above has been imported you can simply edit scripts as applicable in PowerShell ISE meaning any large amendments or creation of scripts themselves should become a much simpler task in itself. Also, since this is a simple one-liner its easy to remember for the next time or can be added into any scripts in the future if you run them as scheduled tasks to ensure the PowerShell module is imported. This is great for automation to ensure your automation scripts don’t fail.
Additional Details: Exchange
If you want to find more details please visit the attached tech net article from Microsoft for more details.
If you want to find more details out on Exchange Online please check out my other blog posts.
Please feel free to drop a comment below or share this blog post if it has helped you.
One Comment