kakaka1kakaka 2014-09-22 07:56
浏览 2118

C#远程调用powershell访问lync服务器 报错问题

如题,下面是代码和错误信息:

代码:

string server = Convert.ToString(ConfigurationManager.AppSettings["serverName"]);
        string username = Convert.ToString(ConfigurationManager.AppSettings["userName"]);
        string str_password = Convert.ToString(ConfigurationManager.AppSettings["userPassword"]);
        string uri = "https://" + server + "/OcsPowerShell";
        string shellUri = "http://schemas.microsoft.com/powershell/Microsoft.Powershell";
        SecureString secPwd = new SecureString();
        foreach (char c in str_password.ToCharArray())
        {
            secPwd.AppendChar(c);
        }
        RunspaceConfiguration config = RunspaceConfiguration.Create();
        WSManConnectionInfo connInfo = new WSManConnectionInfo(new Uri(uri), shellUri, new PSCredential(username, secPwd));
        Runspace runspace = RunspaceFactory.CreateRunspace(connInfo);
        try
        {
            runspace.Open();
        }
        catch (Exception ex)
        {
            //SystemLog.Error("",ex.ToString());
        }
        finally
        {
            runspace.Dispose();
        }

错误信息:

Error: time:15:37:14 --- 创建远程Runspace时报错--- 错误信息:System.Management.Automation.Remoting.PSRemotingTransportException: 连接到远程服务器 lyncserver.contoso.com 失败,并显示以下错误消息: 目标计算机(lyncserver.contoso.com:443)上的服务器证书包含以下错误:
无法检查 SSL 证书吊销。用于检查吊销的服务器可能不可访问。 有关详细信息,请参阅 about_Remote_Troubleshooting 帮助主题。
在 System.Management.Automation.Runspaces.AsyncResult.EndInvoke()
在 System.Management.Automation.Runspaces.Internal.RunspacePoolInternal.EndOpen(IAsyncResult asyncResult)
在 System.Management.Automation.Runspaces.Internal.RemoteRunspacePoolInternal.Open()
在 System.Management.Automation.RemoteRunspace.Open()
在 IWS.ADM.Framework.DataProviders.LyncDAL.InitRunspace()


哪位大神遇见过此问题,还请告诉怎么解决,谢谢。

  • 写回答

0条回答

    报告相同问题?

    悬赏问题

    • ¥15 C++ 头文件/宏冲突问题解决
    • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
    • ¥50 安卓adb backup备份子用户应用数据失败
    • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
    • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
    • ¥30 python代码,帮调试
    • ¥15 #MATLAB仿真#车辆换道路径规划
    • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
    • ¥15 数据可视化Python
    • ¥15 要给毕业设计添加扫码登录的功能!!有偿