Connecting to Exchange Online with a Certificate and C#

Copper Contributor

Anyone using c# to connect to Exchange online? I am running into a problem that I can't seem to make progress on.


I have the following snippet of code trying to connect to exchange online:

public Runspace getSpace() {
    String schema = "";
    Uri server = new Uri("");
    string certificateThumbprint = "thumbprint";

    WSManConnectionInfo connectionInfo = new WSManConnectionInfo(server, schema, certificateThumbprint);
    Runspace rsp = RunspaceFactory.CreateRunspace(connectionInfo );
    return rsp;

Which results in:

System.Management.Automation.Remoting.PSRemotingTransportException: Connecting to remote server failed with the following error message :  For more information, see the about_Remote_Troubleshooting Help topic.
   at System.Management.Automation.Runspaces.AsyncResult.EndInvoke()

I know the cert is working because when I do the following I am able to connect:

Connect-ExchangeOnline -AppId "application guid" -Organization "" -CertificateThumbprint "thumbprint"

Any ideas on what I could try next? Thanks!

1 Reply
Did you ever get a resolution to this?