Hi,
I am writing a c# web application to run some exchange server powershell command. The code is below.
The username and password I use is my Window Authentication. For some reason, the program works but in a few minute (for a little bit while after), my account will get locked.
Any suggestion my account get locked would be appreciated.
string pwd="somepassword";string SHELL_URI = "http://schemas.microsoft.com/powershell/Microsoft.Exchange";
System.Uri serverUri = new Uri(String.Format("http://{0}/powershell?serializationLevel=Full", "somemachine"));
for (int i = 0; i < pwd.Length; i++)
{
securePwd.AppendChar(pwd[i]);
}
PSCredential psCredential = new PSCredential("someUserName", securePwd);
RunspaceConfiguration rc = RunspaceConfiguration.Create();
WSManConnectionInfo wsManInfo = new WSManConnectionInfo(serverUri, SHELL_URI, psCredential);
using (Runspace rs = RunspaceFactory.CreateRunspace(wsManInfo))
{
wsManInfo.MaximumConnectionRedirectionCount = 1;
rs.Open();
PowerShell psh = PowerShell.Create();
psh.Runspace = rs;
...
rs.Close();
}