gpt4 book ai didi

powershell - 什么安全设置阻止远程 PowerShell 2.0 访问 UNC 路径

转载 作者:行者123 更新时间:2023-12-03 22:24:01 25 4
gpt4 key购买 nike

这太疯狂了,我从 PowerShell 开始。当然,我需要远程进行管理员工作。

一个简单的

dir \\server\share\folder

只是拒绝工作,我收到此错误
Get-ChildItem : Cannot find path '\\server\share\folder' because it does not exist.
+ CategoryInfo : ObjectNotFound: (\\server\share\folder:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

对我来说,很明显这是一个访问权限问题。我们在公司确实有一个域名。我在 VNC 上使用完全相同的用户帐户登录到服务器,我可以看到 UNC 路径。但是每当我尝试使用远程连接从桌面复制文件时。就是不行!!!!

我可以做很多其他的事情,所以我很肯定我有联系。

最佳答案

要使其正常工作,您必须同时配置本地和远程计算机。

在远程服务器上 ,运行以下命令:

 Enable-WSManCredSSP -Role server

如果您运行 Get-WSManCredSSP,您将知道配置正确。 cmdlet 并获得以下输出:

The machine is not configured to allow delegating fresh credentials. This computer is configured to receive credentials from a remote client computer.



在您的本地计算机上 ,在管理 PowerShell 提示符下,您需要在 PowerShell 中允许凭据委派。运行以下命令:
 Enable-WSManCredSSP -Role Client -DelegateComputer <REMOTE_COMPUTER_NAME>

您可以使用 * 表示 REMOTE_COMPUTER_NAME 来启用所有服务器.

当您运行 Get-WSManCredSSP 并获得以下输出时,您将知道它已正确配置:

The machine is configured to allow delegating fresh credentials to the following target(s): wsman/REMOTE_SERVER_NAME
This computer is not configured to receive credentials from a remote client computer.



在您的本地机器上 ,更新组策略以允许将您的凭据委派给远程服务器。
  • 打开 gpedit.msc 并浏览到计算机配置 > 管理模板 > 系统 > 凭据委派。
  • 双击“允许使用仅 NTLM 服务器身份验证委派新凭据”。
  • 启用该设置并将构建服务器作为 WSMAN/BuildServerName 添加到服务器列表中。 (您可以通过输入 WSMAN/* 来启用所有服务器。)

  • 然后,当您需要在远程服务器上运行命令时, 您不能使用任何 *-PSSession 命令 因为 CredSSP 不能使用缓存的凭据。您必须使用 Invoke-Command 开始 session ,并使用 CredSSP 作为 Authentication 参数的值,如下所示:
    Invoke-Command -ScriptBlock { # remote commands here } `
    -ComputerName <REMOTE_COMPUTER_NAME> `
    -Authentication CredSSP `
    -Credential <USERNAME>

    关于powershell - 什么安全设置阻止远程 PowerShell 2.0 访问 UNC 路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8362057/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com