Forum Discussion

Alexej-Grenz's avatar
Alexej-Grenz
Copper Contributor
May 11, 2023

Connect to Exchange 2019 Management Shell over HTTPS

Hello Community,

 

we have an Exchange Server 2019 CU12 Hybrid environment and we want to automate the common Exchange tasks with Service Now (create mailbox, Distribution list) as i have to create the items on the on-prem Exchange servers i need th Exchnage CMDlets to push the commands with Powershell scripts.

As the Service Now Mid Server don't have this Exchange Cmdlets installed my idea was to connect the Service Now Mid Server with the Exchange management Shell and the run the commands. Based on Security reasons we want to connect the Exchange Management Shell over HTTPS and not over HTTP. Unfortunately, Microsoft only documented HTTP connection "https://learn.microsoft.com/en-us/powershell/exchange/connect-to-exchange-servers-using-remote-powershell?view=exchange-ps"

I found also a how-to to enable SSL for Management Shell o the Exchange Server 2016. I follwed the instruction but its still not working.

Ist there a Best practice available to allow Exchange Management Shell connections over HTTPS?

 

Best regards,

Alex

  • Andres-Bohren's avatar
    Andres-Bohren
    Steel Contributor

    Hi Alexej-Grenz 

     

    You're probably looking for some code like this

     

    #Using Basic Auth
    $ServernameFQDN = "servername.addomain.tld"
    $conURI = "https://$ServernameFQDN/PowerShell/"
    $Username = "domain\username"
    $Password = ConvertTo-SecureString -String "YourPassword" -AsPlainText -Force
    $Cred = New-Object System.Management.Automation.PSCredential $Username,$Password
    $SessionOption = New-PSSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
    $ExSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri $conURI -Authentication "Basic" -Credential $cred -SessionOption $SessionOption
    Import-PSSession -Session $ExSession -DisableNameChecking -AllowClobber | Out-Null

     

    Regards

    Andres

Resources