【发布时间】:2016-10-13 08:47:12
【问题描述】:
我用 C# 制作了一个应用程序,它使用 powershell 远程处理远程更新我们域中计算机的主机文件。它工作得很好,但我们公司的入门级 IT 支持职位没有他们的域帐户属于我们工作站的管理员组。但是,他们可以使用本地管理员帐户。我正在尝试添加“使用其他帐户连接”功能,但很快遇到了一些障碍。除了一个,我已经修复了所有这些:
我无法使用远程本地帐户对其进行身份验证,并且我所有的谷歌搜索都没有产生任何解决方案。
这是我用来更新主机文件的代码:
psInstance.AddScript("Invoke-Command -ComputerName " + computerName + " -ScriptBlock { \"" +
hostsTextBox.Text.Replace("\"", "`\"") + "\" | Out-File c:\\windows\\system32\\drivers\\etc\\hosts }" +
(differentCredentialsCheckbox.Checked ? "-Credential \"" + computerName + "\\\" -Authentication Negotiate " : ""));
当使用不同的凭据时,它会失败并显示以下消息:
[COMPUTERNAME] Connecting to remote server COMPUTERNAME failed with the following
error message : WinRM cannot process the request. The following error with error code
0x8009030e occurred while using Negotiate authentication: A specified logon session
does not exist. It may already have been terminated. This can occur if the provided
credentials are not valid on the target server, or if the server identity could not
be verified. If you trust the server identity, add the server name to the
TrustedHosts list, and then retry the request. Use winrm.cmd to view or edit the
TrustedHosts list. Note that computers in the TrustedHosts list might not be
authenticated. For more information about how to edit the TrustedHosts list, run the
following command: winrm help config. For more information, see the
about_Remote_Troubleshooting Help topic.
+ CategoryInfo : OpenError: (COMPUTERNAME:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : 1312,PSSessionStateBroken
现在,如果我理解正确,则仅在以下情况下使用远程本地帐户才有效:
连接是使用 HTTPS 建立的,但这会带来一系列问题。需要为每台计算机创建一个证书,该工具旨在使用并安装在我们的 500 多个工作站上。此外,如果技术人员获得了一台新计算机,则需要重新开始该过程(这种情况不应该经常发生,但可能性不为零)
计算机使用 TrustedHosts 相互信任,但这也存在与 #1 相同的问题。
注意:我们是在一家跨国公司的分支机构之一工作的本地 IT 团队,我们无法访问 GPO,因此我们没有任何简单的方法可以将证书推送到我们的工作站.此外,我们分支机构中的每个组都隔离在自己的 VLAN 上。
有没有人能想出一种方法来实现我想要做的事情?
【问题讨论】:
-
您是否考虑过设置一个在管理员帐户下运行的受限委托会话,并让他们通过它运行您的应用程序?
标签: powershell powershell-remoting