title: Access Exchange Using Powershell in C#
body: <p>Im trying to access the exchange server using powershell in c#
  Here is the code i am trying to use</p>
  
  <pre><code>            WSManConnectionInfo ConnectionInfo = new WSManConnectionInfo(new Uri(@"http://myexchangeserver.com"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", (PSCredential)null);
              ConnectionInfo.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
              using (Runspace runspace = RunspaceFactory.CreateRunspace(ConnectionInfo))
              {
                  using (PowerShell PS_Instance = PowerShell.Create())
                  {
                      PS_Instance.AddCommand("Get-MailboxPermission -Identity UAT_TestGeneric");
  
                      runspace.Open();
                      PS_Instance.Runspace = runspace;
                      Collection&lt;PSObject&gt; results = PS_Instance.Invoke();
  
                      if (PS_Instance.Streams.Error.Count &gt; 0)
                      {
                          //Couldnt Connect To Server
                      }
                      else
                      {
                          //Do Stuff
                      }
                  }
  </code></pre>
  
  <p>i keep getting this error message</p>
  
  <blockquote>
    <p>The WinRM client received an HTTP status code of 403 from the remote
    WS-Management service. For more information, see the
    about_Remote_Troubleshooting Help topic.</p>
  </blockquote>
  
  <p>I have checked the exchange servers powershell IIS folder and it doesnt require SSL as indicated here <a href="https://support.microsoft.com/en-au/kb/2276957" rel="nofollow noreferrer">https://support.microsoft.com/en-au/kb/2276957</a>.</p>
  
  <p>Is there any one out there that can assist?
  Thanks.</p>