【问题标题】:Can't enter remote powershell 7.1 session无法进入远程 powershell 7.1 会话
【发布时间】:2020-12-03 18:26:48
【问题描述】:

能够针对Microsoft.PowerShell (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 的会话)。

【问题讨论】:

  • 似乎通过使用户成为管理员它可以工作......
  • 最重要的是,仍然无法成功运行Copy-Item...叹息

标签: powershell powershell-remoting winrm powershell-7.0


【解决方案1】:

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

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

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

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

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

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

Docs here 对 v5.1 和 v7 稍作改动,然后链接到 here 提到安装脚本,所以可能有些东西已经漏掉了。

【讨论】:

    【解决方案2】:

    我遇到了同样的错误。我从 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

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

    【讨论】:

      猜你喜欢
      • 2013-04-10
      • 1970-01-01
      • 1970-01-01
      • 2013-07-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多