Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is probably a powershell related error. If you are running the code from a remote machine (not the exchange server), you have to enable remote powershell access for the user in question and make sure the firewall(s) allows connections to the exchange server on port 80. On the exchange server:</p> <pre><code>Set-User –identity username –RemotePowershellEnabled $True </code></pre> <p>The user also has to be a member of an exchange management role allowing mailbox creation. </p> <p>If you are using a load balanser and/or have a DAG you may have to set up an Alternate Service Account to enable Kerberos authentication. See <a href="http://technet.microsoft.com/en-us/library/ff808313.aspx" rel="nofollow">http://technet.microsoft.com/en-us/library/ff808313.aspx</a> for details. I had to enable this to make the code run in my environment. I modified the code a bit to just test if I was able to run exchange powershell commands. The following code responds with the full name of the USERIDENT user if successful.</p> <pre><code>static void Main(string[] args) { SecureString password = new SecureString(); string str_password = "PASS"; string username = "domain\\user"; //FQDN is ofcourse the (fully qualified) name of our exchange server.. string liveIdconnectionUri = "http://SERVERFQDN/Powershell?serializationLevel=Full"; foreach (char x in str_password) { password.AppendChar(x); } PSCredential credential = new PSCredential(username, password); WSManConnectionInfo connectionInfo = new WSManConnectionInfo((new Uri(liveIdconnectionUri)), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential); Runspace runspace = null; PowerShell powershell = PowerShell.Create(); PSCommand command = new PSCommand(); command.AddCommand("Get-Mailbox"); command.AddParameter("Identity", "USERIDENT"); powershell.Commands = command; try { connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Default; runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(connectionInfo); runspace.Open(); powershell.Runspace = runspace; Collection&lt;PSObject&gt; commandResults = powershell.Invoke&lt;PSObject&gt;(); foreach (PSObject result in commandResults) { Console.WriteLine(result.ToString()); } } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { runspace.Dispose(); runspace = null; powershell.Dispose(); powershell = null; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload