Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用C连接到SkyLineConnector#_C#_Powershell_Exchangewebservices_Skype For Business - Fatal编程技术网

C# 使用C连接到SkyLineConnector#

C# 使用C连接到SkyLineConnector#,c#,powershell,exchangewebservices,skype-for-business,C#,Powershell,Exchangewebservices,Skype For Business,我希望通过C#连接到SkyLineConnector端点,然后能够执行从端点下载的命令 类似于为Exchange命令建立连接的方式 示例:Exchange连接 string severName = "ps.outlook.com/PowerShell-LiveID?PSVersion=2.0"; string userName = "name@domain.com"; string p

我希望通过C#连接到SkyLineConnector端点,然后能够执行从端点下载的命令

类似于为Exchange命令建立连接的方式

示例:Exchange连接

            string severName = "ps.outlook.com/PowerShell-LiveID?PSVersion=2.0";
            string userName = "name@domain.com";
            string password = "Password";

            System.Security.SecureString secureString = new System.Security.SecureString();
            foreach (char c in password)
                secureString.AppendChar(c);
            PSCredential credential = new PSCredential(userName, secureString);
            WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("https://" + severName), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential)
            {
                AuthenticationMechanism = AuthenticationMechanism.Basic,
                SkipCACheck = true,
                SkipCNCheck = true,
                MaximumConnectionRedirectionCount = 4
            };

我试过这个

            string PSServerName = "admingb1.online.lync.com/OcsPowershellOAuth";
            string UserName = "name@domain.com";
            string Password = "password";

            System.Security.SecureString secureString = new System.Security.SecureString();
            foreach (char c in Password)
                secureString.AppendChar(c);
            PSCredential credential = new PSCredential(UserName, secureString);
            WSManConnectionInfo connectionInfo = new WSManConnectionInfo(new Uri("https://" + PSServerName), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential)
            {
                AuthenticationMechanism = AuthenticationMechanism.Basic,
                SkipCACheck = true,
                SkipCNCheck = true,
                MaximumConnectionRedirectionCount = 4
            };
运行上述命令会导致以下错误

System.Management.Automation.Remoting.PSRemotingTransportException : Connecting to remote server admingb1.online.lync.com failed with the following error message : The WinRM client cannot process the request. The authentication mechanism requested by the client is not supported by the server or unencrypted traffic is disabled in the service configuration. Verify the unencrypted traffic setting in the service configuration or specify one of the authentication mechanisms supported by the server.  To use Kerberos, specify the computer name as the remote destination. Also verify that the client computer and the destination computer are joined to a domain. To use Basic, specify the computer name as the remote destination, specify Basic authentication and provide user name and password. Possible authentication mechanisms reported by server: For more information, see the about_Remote_Troubleshooting Help topic.

这是正确的方法还是需要完全不同的方法


任何帮助都将不胜感激。

您在尝试此代码时是否遇到特定问题?我收到了身份验证错误。我试过基本的,协商的,默认的,你真的需要更具体一些。更新您的问题以显示您看到的确切错误。但从我在网上看到的情况来看,连接到此服务所需的powershell代码似乎有点不同。这里有一个例子:-周围有几个类似的。我使用类似的东西通过PowerShell连接。只是不知道如何在C#中复制。虽然我确实发现了一个问题,它部分地完成了工作