troubleshooting Question

Powershell: Load Exchange Tools

Avatar of whenz
whenz asked on
1 Comment1 Solution513 ViewsLast Modified:
I am creating an universal Powershell script for Exchange 2007/2010 installations.  

I want to have a function which checks if the Exchange SnapIn is already loaded.  Depending on the installation, it only should try to load the Exchange 2007 or Exchange 2010 SnapIn.

That's what I have at the moment which is creating a Warning as it either only finds one or the other Snapin.

function LoadExchangeTools {
	if (-not (Get-pssnapin | ? {$ -like 'Microsoft.Exchange'})) {
		Add-PSSnapin Microsoft.Exchange.Management.PowerShell.e2010
		Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin

I want a function which checks which Exchange version is installed and then only tries to load the appropriate Snapin.

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 1 Comment.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 1 Comment.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros