I'm trying to configure my LyncServer via a WcfService that itself does PowerShell remoting to run Cmdlets on the Lync machine. I successfully import the Lync module, but when i try to call and Lync cmdlet, e.g. Get-CsUser i receive a error in powershell.Streams.Error:
Active Directory error "-2147016672" occurred while searching for domain control lers in domain "my.test.domain": "An operations error occurred."
This is how i create my Runspace:
PSCredential psCred = new PSCredential(this.Credentials.Domain + "\\" + this.Credentials.UserName, this.Credentials.SecurePassword);
WSManConnectionInfo wsman = new WSManConnectionInfo(uri, c_powerShellShema, psCred);
wsman.AuthenticationMechanism = AuthenticationMechanism.Default;
//wsman.AuthenticationMechanism = AuthenticationMechanism.Kerberos;
//wsman.ProxyAuthentication = AuthenticationMechanism.Negotiate;
Runspace retval = RunspaceFactory.CreateRunspace();//wsman);
retval.Open();
and my powershell calls
PowerShell powerShell = PowerShell.Create();
powerShell.Runspace = this.Runspace;
powerShell.AddScript("Import-Module Lync");
powerShell.Invoke();
powerShell.Streams.ClearStreams();
powerShell.AddScript("Get-CsUser);
powerShell.Commands.AddCommand("Out-String");
var retval = powerShell.Invoke();
foreach (var o in retval)
Console.WriteLine(o.ToString());
foreach (var e in powerShell.Streams.Error)
Console.WriteLine(e.ToString());
Any idea? the User that is used in the Runspace is the same user that i used to do all the lync configuration via the lync management console, so he has all access permissions he need.