C#을 통해 powershell을 사용하여 Exchange 2010 작업을 수행하고 싶습니다. 아래 그림과 같이 연결을 설정할 수 있습니다. 내 질문 : 명시 적으로 자격 증명을 지정하지 않고 어떻게 연결을 만들 수 있습니까? 현재 Windows 사용자 ID를 통해 가져올 수 없습니까?Exchange 2010 + Powershell 및 C# 문제 현재 사용자로부터 PSCredential 가져 오는 중
SecureString password = new SecureString();
string str_password = "pass";
string username = "userr";
string liveIdconnectionUri = "http://exchange.cccc.com /Powershell?serializationLevel=Full";
foreach (char x in str_password)
{
password.AppendChar(x);
}
PSCredential credential = new PSCredential(username, password);
// Set the connection Info
WSManConnectionInfo connectionInfo = new WSManConnectionInfo((new Uri(liveIdconnectionUri)), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Default;
CredentialCache.DefaultCredentials 및 DefaultNetworkCredentials는 비어 있습니다. – hoetz