System.Management.Automation class I use the c # PowerShell exchange programs that access the server, increase the tasks of
e-mail accounts, a program error access denied;
PSCredential credentials = new PSCredential(UserName, ssRunasPassword);
//ExchangeUri=ExUri
WSManConnectionInfo connectionInfo = new WSManConnectionInfo(ExchangeUri, "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credentials);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Basic;
Runspace runspace = RunspaceFactory.CreateRunspace(connectionInfo);
runspace.Open();