Forum Discussion

VibhorM's avatar
VibhorM
Copper Contributor
Apr 10, 2019

Calling Exchange Online PowerShell Cmdlets from C# With Modern Authentication

Hi Currently We can calling Exchange Online Commandlets With the below code :

 WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("https://outlook.office365.com/PowerShell-LiveID"), exchangeSchema,
                   PowershellCommonUtilities.GetPSCredential(connectInfo.UserName, connectInfo.Password)); connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
                connectionInfo.IdleTimeout = idleTimeout;
                connectionInfo.OpenTimeout = connectionTimeout;

                exchangerunspacepool = RunspaceFactory.CreateRunspacePool(minRunSpace, maxRunspace, connectionInfo);

 

We need to move this basic Authentication to Modern Authentication. Please let me know if anyone has achieved it.

Resources