Lyncマシンでコマンドレットを実行するためにPowerShellリモーティングを実行するWcfServiceを介してLyncServerを構成しようとしています。Lyncモジュールを正常にインポートしましたが、Lyncコマンドレット(Get-CsUserなど)を呼び出そうとすると、powershell.Streams.Errorでエラーが発生します。
ドメイン「my.test.domain」でドメインコントローラーの検索中にActiveDirectoryエラー「-2147016672」が発生しました:「操作エラーが発生しました。」
これが私の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();
そして私のPowerShellは呼び出します
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());
何か案が?Runspaceで使用されるユーザーは、lync管理コンソールを介してすべてのlync構成を行うために使用したのと同じユーザーであるため、必要なすべてのアクセス許可があります。