Forum Discussion
Alexej-Grenz
May 11, 2023Copper Contributor
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...
Andres-Bohren
May 11, 2023Iron 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