KB10105 - Exchange: Remote Connect PowerShell

PowerShell script that can be placed in PowerShell profile folder so en easy connect to a remote Exchange shell is possible.

This one uses Kerberos authentication and is tested against Exchange 2010 and Exchange 2013 servers in default configuration.

Hint: Modify the variable ExchangeServerFQDN to fit your environment so you do not have to use the parameter everytime...

PowerShell profile integration

To use this script without calling it everytime you can create a folder in your My Documents folder called "WindowsPowerShell" an place the content of the script inside a file called "profile.ps1"

Script code:

function Connect-Exchange (
    [string] $ExchangeServerFQDN = "defaultserver.yourdomain.local"
    Write-Host -ForegroundColor Green "Connecting to Exchange shell on server: " -NoNewline
    Write-Host -ForegroundColor Yellow "$ExchangeServerFQDN ... " -NoNewline
    $ExSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$ExchangeServerFQDN/powershell -Authentication Kerberos -ErrorAction SilentlyContinue -WarningAction SilentlyContinue
    try {
        $null = Import-PSSession $ExSession -DisableNameChecking -WarningAction SilentlyContinue -ErrorAction SilentlyContinue -AllowClobber
        Write-Host -ForegroundColor Green "done!"

    catch {
        Write-Host -ForegroundColor Red "failed!"
        Write-Host -ForegroundColor Red "[ERROR] while connecting to Exchange shell on server: $ExchangeServerFQDN"

>> syntax highlighting powered by highlight.js