You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

无gpedit时,如何通过PowerShell修改Allow Remote Shell Access状态?

How to Modify "Allow Remote Shell Access" via PowerShell (No gpedit or GroupPolicy Module Needed)

Got it, since you can't use gpedit.msc and are running into problems importing the GroupPolicy module, working directly with the Windows Registry via PowerShell is your best bet. The "Allow Remote Shell Access" Group Policy setting maps directly to a registry key, so editing this key will give you the same outcome as using the graphical group policy editor.

Here's how to do it:

First, note that the relevant registry path is HKLM:\SOFTWARE\Policies\Microsoft\Windows\WinRM\Service, and the DWORD value AllowRemoteShellAccess controls the setting:

  • 1 = Enabled
  • 0 = Disabled

Enable "Allow Remote Shell Access"

Run this PowerShell script as Administrator:

# Create the registry path if it doesn't exist
if (-not (Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WinRM\Service")) {
    New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WinRM\Service" -Force | Out-Null
}

# Set the value to enable remote shell access
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WinRM\Service" -Name "AllowRemoteShellAccess" -Value 1 -Type DWORD -Force

# Restart the WinRM service to apply changes immediately
Restart-Service WinRM -Force

Disable "Allow Remote Shell Access"

To turn it off, simply change the value to 0 and restart the service:

Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WinRM\Service" -Name "AllowRemoteShellAccess" -Value 0 -Type DWORD -Force
Restart-Service WinRM -Force

A quick note on the GroupPolicy module issue:

If you're getting errors when running Import-Module GroupPolicy, it's almost certainly because you're using a Windows Home edition. Home editions don't include the Group Policy tools (including the module and gpedit.msc) by default, which is why the registry workaround is necessary here.

内容的提问来源于stack exchange,提问作者asur

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.20 08:07:33