1

能够针对Microsoft.PowerShell(5.1)执行此操作,但今天我在 5.1 上遇到了一个已知问题,Copy-Item因此我在远程服务器上安装了 PowerShell 7(在安装程序中选中“启用远程处理”)并试图让它工作。

    $securePassword = ConvertTo-SecureString -AsPlainText -Force -String $Password
    $credential = New-Object -TypeName system.management.automation.pscredential -ArgumentList $Username, $securePassword
    $session = New-PSSession $targetMachineHostName -Credential $credential -ConfigurationName "Microsoft.PowerShell"
    Enter-PSSession $session

以上作品。但是,如果我将 ConfigurationName 更改为 "PowerShell.7.1.0"我得到:

[myserver.com.au] Connecting to remote server myserver.com.au failed with
     | the following error message : <f:WSManFault
     | xmlns:f="http://schemas.microsoft.com/wbem/wsman/1/wsmanfault" Code="2689860592"
     | Machine="myserver.com.au"><f:Message><f:ProviderFault provider="PowerShell.7.1.0"
     | path="C:\Windows\system32\PowerShell\7.1.0\pwrshplugin.dll"></f:ProviderFault></f:Message></f:WSManFault> For more information, see the about_Remote_Troubleshooting Help topic.

在远程服务器上,我在 7.1 powershell 中运行了 enable ps remoting 所以如果我运行Get-PSSessionConfiguration它会返回一堆配置,包括以下内容:

Name          : PowerShell.7.1.0
PSVersion     : 7.1
StartupScript :
RunAsUser     :
Permission    : NT AUTHORITY\INTERACTIVE AccessAllowed, BUILTIN\Administrators AccessAllowed, BUILTIN\Remote
                Management Users AccessAllowed

错误所指的dll存在于机器上。

我使用的用户凭据适用于远程计算机上的本地用户,该用户不是管理员,但属于该Remote Management Users组。

另外值得注意的是远程机器本身(作为不同的管理员本地帐户,我可以启动一个会话localhost)。

4

2 回答 2

1

在使用户成为管理员后,我能够连接,但我之前已经竭尽全力在 5.1 上使非管理员成为可能。

出于兴趣,我尝试让用户完全控制C:\Windows\system32\PowerShell\7.1.0,然后我可以连接......

仍然很想知道发生了什么以及我是否在做正确的事情或所需的最低权限。

该文件夹的最低安全权限似乎是:

  • 读取和执行
  • 列出文件夹内容

写是奇怪的,但没有它我得到那个错误。我已将这些权限分配给“远程管理用户”组。

此处的文档涉及 v5.1 与 v7 的一些内容,然后链接到此处提及安装脚本,因此可能有些东西已经从裂缝中消失了。

于 2020-12-03T18:54:46.490 回答
0

我遇到了同样的错误。我从 Microsoft Store 安装了 PowerShell 7,然后运行Enable-PSRemoting​​. 我收到此错误,因此我将其卸载并从使用 MSI 的 WinGet 重新安装。那也没有用。我再次尝试跑步Enable-PSRemoting,但没有任何改变。

我跑了Install-PowerShellRemoting.ps1,它给了我两个关于已经存在的东西的错误,并没有解决问题。但是,我能够通过执行以下操作来解决问题:

  1. 删除 PowerShell 7 插件:Remove-Item 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\Plugin\PowerShell.7','HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\Plugin\PowerShell.7.1.1'.
  2. 再跑Install-PowerShellRemoting.ps1

我不确定有什么区别,但删除并允许脚本再次生成它为我修复了它。

于 2021-01-18T20:15:16.873 回答