Wednesday, August 9, 2017

Connect Remote Exchange Server Function

You can use below function to make connection to remote PS in Exchange 2016.
You will need to change following string $server ="" to make it work for you environment.

# Connect Remote PS Exchange 2016 Server, Specify Server to connect.

# Change the server FQDN with server name you desire.
Function Connect_E16 {
        [Parameter( Mandatory=$false)]
        [string]$server =""
        $session = New-PSSession -ConfigurationName Microsoft.Exchange `
        -ConnectionUri http://$srv/PowerShell/ `
        -Authentication Kerberos
         Import-PSSession $session -AllowClobber

write-host $null
Write-host "_Connecting Exchange 2016 Servers"

Oz Casey, Dedeal
Systems Engineer (Blog) (Blog) (Twitter)

1 comment:

Damian Garbus said...

Sometimes is good to use import-pssession with -prefix paramiter. For example when you want to connect to exchange onpremise and exchange online ��