Hi. I am trying to convert a c# unattended application from using basic auth to the new certificate based method and have tried using several suggested options, the latest being a process based on that indicated by JrouziesM 12-16-2020. However I still have problems with the following:
var certId = "xxxxxx";
var appId = "yyyyy";
var org = "zzzzz";
var proxyType = "IEconfig";
InitialSessionState initSession = InitialSessionState.CreateDefault();
initSession.ImportPSModule(new[] { "ExchangeOnline" });
Runspace Runspace = RunspaceFactory.CreateRunspace(initSession);
Runspace.Open();
PowerShell powershell_2 = PowerShell.Create();
powershell_2.Runspace = Runspace;
PSCommand session = new PSCommand();
session.AddCommand($"Connect-ExchangeOnline -ConnectionUri {strRemoteComputerUri} -ProxyAccessType {proxyType} -CertificateThumbPrint {certId} -AppID {appId} -Organization {org}");
session.AddScript("get-mailbox -identity xyz");
Collection<PSObject> output = powershell_2.Invoke();
However, this just seems to time out or not proceed to an output being generated from the Invoke(). No errors are trapped when I include it in a try/catch.
Is there something that I am missing in this approach?