Powershell Remote to Exchange 2010 Server

  • by

Please refer to the steps below on how to connect to Exchange 2010 Server via PowerShell from Internet

Please enable Basic Authentication in IIS

Save your password to .txt file

"XXXXXXX" | ConvertTo-SecureString -AsPlainText -Force | ConvertFrom-SecureString | Out-File "C:\scripts\AventisLab.txt"

Connect to Exchange 2010 if you are using public trusted SSL Certificate

#PowerShell Remote to Exchange 2010 Server - AventisLab.com
$UserName = "mylab\administrator"
$Password = Get-Content C:\Scripts\AventisLab.txt| ConvertTo-SecureString

#Specify Credential with password 
$Credential = new-object -typename System.Management.Automation.PSCredential -ArgumentList $UserName,$Password

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://mail.aventislab.com/powershell `
-Credential $Credential -Authentication  Basic -AllowRedirection

Please include the following to skip to check the CA if your Exchange 2010 server is using non-trusted SSL Certificate

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://mail.aventislab.com/powershell `
-Credential $Credential -Authentication  Basic -AllowRedirection

Import the PSSession and you are connected!!

Import-PSSession $Session