Link to home
Start Free TrialLog in
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!!
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial