Avatar of whenz
whenz asked on

Powershell: Load Exchange Tools

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 | ? {$_.name -like 'Microsoft.Exchange'})) {
		Add-PSSnapin Microsoft.Exchange.Management.PowerShell.e2010
		Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
	}
}

Open in new window



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

Thanks!!
Powershell

Avatar of undefined
Last Comment
Subash Sundharan

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Subash Sundharan

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy