If ((Get-PSSnapin | where {$_.Name -match "Microsoft.Exchange.Management.PowerShell.E2010"}) -eq $null) { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 . $env:ExchangeInstallPathinRemoteExchange.ps1 Connect-ExchangeServer -auto -AllowClobber }