
我正在嘗試在以工作群組模式運行的 Windows 2008 R2 Server 上啟用 Powershell 遠端處理。
我在 PowerShell 控制台中執行了命令 Enable-PSRemoting。
PS C:\Windows\system32> Enable-PSRemoting
WinRM Quick Configuration Running command "Set-WSManQuickConfig" to enable this machine for remote management through WinRM service This includes:
1. Starting or restarting (if already started) the WinRM service
2. Setting the WinRM service type to auto start
3. Creating a listener to accept requests on any IP address
4. Enabling firewall exception for WS-Management traffic (for http only).
Do you want to continue? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): y WinRM already is set up to receive requests on this machine. Set-WSManQuickConfig : Access is denied. At line:50 char:33
+ Set-WSManQuickConfig <<<< -force
+ CategoryInfo : InvalidOperation: (:) [Set-WSManQuickConfig], InvalidOperationException
+ FullyQualifiedErrorId : WsManError,Microsoft.WSMan.Management.SetWSManQuickConfigCommand
我以管理員群組成員的身分登錄,並以管理員身分執行控制台。
答案1
剛剛在幾個系統上遇到並解決了這個問題。在這種特殊情況下,這兩個系統不是網域的一部分,而且使用者帳戶不是原始的「管理員」帳戶,而是一個新帳戶,也是本機管理員群組的成員。
解決方案來自我偶然發現的以下部落格文章:本機上的 WinRM 存取被拒絕。簡而言之,從命令提示字元執行以下命令(以管理員身份啟動):
reg add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v LocalAccountTokenFilterPolicy /t REG_DWORD /d 1 /f
之後,以管理員身分重新啟動 PowerShell 提示字元並重新執行Enable-PSRemoting
,就這麼簡單。
答案2
對於 Power Shell 遠端處理的任何問題,有兩個重要資源。
第一個是help about_Remote_Troubleshooting
,這是一個廣泛的參考。
第二個是在網路上搜尋您遇到的錯誤。我找到了一個 PowerShell 團隊部落格文章有這個清單:
- 我的機器已連接到網域。
- 我以管理員身分登入
- PowerShell 已提升啟動。
- 我的密碼不為空
其中之一可以解決您的問題嗎?
答案3
我最近遇到了同樣的錯誤訪問被拒絕,同時嘗試在 Windows 2008 R2 的託管版本上啟用 PSRemoting。
我發現我的託管公司在防火牆規則上應用了群組策略,該規則在嘗試啟用 PSRemoting 時的第四步驟中進行了修改:
4. 為 WS-Management 流量啟用防火牆例外(僅適用於 http)
修復步驟:
1) 點選開始功能表 >> 管理工具 >> Windows 防火牆與進階安全性
2) 點選入站規則>> 新規則>> 選擇「預先定義」選項,然後從下拉清單中選擇Windows 遠端管理>> 按一下下一步
3)現在,取消選擇 Windows 遠端管理相容模式(HTTP-In) 並選擇 Windows 遠端管理模式(HTTP-In) >> 按一下下一步 >> 允許連線 >> 完成
這是我之前使用過的用於調試此功能的有用資源清單我發現了上述修復:
故障排除參考:
檢查您的帳戶是否位於本機管理員群組:
powershell> whoami /all
Powershell 團隊 - 啟用 PSRemoting(4個常見故障排除步驟)
如何在遠端電腦上執行 powershell 命令(網域與工作組設定)
其他主題:
嘗試在 SharePoint 上設定 PSRemoting?
使用 PowerShell 遠端處理技術來管理 SharePoint 場
嘗試在 Windows XP 上設定 PSRemoting?
在 Windows XP SP3 中啟用 PSRemoting 時出錯
您是否在非英語計算機上設定 PSRemoting? - 將其更改為英語
參考 1 - 未指定語言
參考資料 2 - 西班牙語/德語
您是否正在使用 VirtualBox 並嘗試設定 PSRemoting?
Virtualbox 並需要啟用 CredSSP
VirtualBox 和設定 PSRemoting 出現存取被拒絕錯誤
答案4
有時,winrm 和「存取被拒絕」的問題是由無效的憑證配置引起的。這裡有詳細資訊:https://docs.microsoft.com/en-us/troubleshoot/iis/http-403-forbidden-access-website#cause-2-non-self-signed-certificates-are-in-trusted-root-certification-權威證書存儲