Currently, I have a C# module that can connect to Exchange server to run EX related powershell. Below is sample code to create the runspace
Code: Select all
var connectionInfo = new WSManConnectionInfo();
connectionInfo.Credential = new PSCredential(UserName, Password);
connectionInfo.ComputerName = ServerName;
connectionInfo.ConnectionUri = new Uri("https://" + ServerName + "/powershell");
connectionInfo.ShellUri = "Microsoft.Exchange";
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
Runspace rs = RunspaceFactory.CreateRunspace(connectionInfo);
rs.Open()
Thanks