Server 2012 remote powershell with C#
C#
1
Posts
1
Posters
0
Views
1
Watching
-
I'm having the toughest time finding / figuring out how to get remote powershell working with 2012. Currently this is my code:
private void OpenRunspace(string username, string password, ref Runspace remoteRunspace)
{
// Convert plain text password to secure string
SecureString pass = new SecureString();
foreach (char c in password.ToCharArray())
{
pass.AppendChar(c);
}PSCredential psc = new PSCredential(username, pass); WSManConnectionInfo wmci = new WSManConnectionInfo(new Uri("http://" + ConfigurationManager.AppSettings\["ExchangeServer"\] + "/powershell"), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", psc); wmci.AuthenticationMechanism = AuthenticationMechanism.Kerberos; wmci.ProxyAuthentication = AuthenticationMechanism.Negotiate; wmci.SkipCACheck = true; wmci.SkipCNCheck = true; remoteRunspace = RunspaceFactory.CreateRunspace(wmci); }
The error I keep getting is "Access is denied". I've verified the credentials I am passign to it is part of the REmote Management Users group on that local server, ran the Set-User "Administrator" powershell enabled command in Exchange 2013 What else am I missing here?