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 ="EXC01.smtp25.org" 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 {
    param(
        [Parameter( Mandatory=$false)]
        [string]$server ="EXC01.smtp25.org"
)
        $session = New-PSSession -ConfigurationName Microsoft.Exchange `
        -ConnectionUri http://$srv/PowerShell/ `
        -Authentication Kerberos
         Import-PSSession $session -AllowClobber
}

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

Oz Casey, Dedeal
Systems Engineer
http://smtp25.blogspot.com/ (Blog)
http://telnet25.wordpress.com/ (Blog)
https://twitter.com/Message_Talk (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 ��