Connect-ExchangeOnline EXO V2 - Facing issues while connecting to Exchange Online PowerShell using a local certificate for unattended script scenario

Nijas B Rawther 1 Reputation point
2021-10-30T13:20:17.207+00:00

Details: We are getting the following exception while connecting to Exchange Online PowerShell using a local certificate using the following command

Connect-ExchangeOnline -CertificateFilePath "xyz.pfx" -CertificatePassword (ConvertTo-SecureString -String "xyz" -AsPlainText -Force) -AppID "xyz" -Organization "xyz.onmicrosoft.com"

Connecting to remote server outlook.office365.com failed with the following error message : The SSL connection cannot be established. Verify that the service on the remote host is properly configured to listen for HTTPS requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig -transport:https". For more information, see the about_Remote_Troubleshooting Help topic.

Exchange | Exchange Server | Management
Exchange | Exchange Server | Management
The administration and maintenance of Microsoft Exchange Server to ensure secure, reliable, and efficient email and collaboration services across an organization.
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 123K Reputation points MVP Volunteer Moderator
    2021-10-30T14:21:23.69+00:00

    When using CertificateFilePath, the -CertificatePassword parameter is mandatory. Other than that, make sure that you have granted the appropriate admin role to the service principal corresponding to your "Testing app".

    To exclude any network-related issues, make sure you can connect with "regular" PowerShell session on the same machine.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.