通过PowerShell在Windows Server上禁用IE安全性

37

经常会出现这种情况,我启动一个带有Windows Server的虚拟机,但由于IE安全性问题,无法访问互联网。请问是否有一个简单明了的PowerShell脚本来禁用IE安全性?


你想要禁用什么?ESC键?保护模式? - Andy Arismendi
2
是的,IE ESC(这里有更多字符以允许我发布此评论????) - Chris Hayes
2个回答

58
function Disable-InternetExplorerESC {
    $AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
    $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
    Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0
    Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0
    Stop-Process -Name Explorer
    Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green
}
function Enable-InternetExplorerESC {
    $AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
    $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
    Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 1
    Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 1
    Stop-Process -Name Explorer
    Write-Host "IE Enhanced Security Configuration (ESC) has been enabled." -ForegroundColor Green
}
function Disable-UserAccessControl {
    Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 00000000
    Write-Host "User Access Control (UAC) has been disabled." -ForegroundColor Green    
}

将此内容保存为 .ps1 文件。

然后在提示符处输入一个句点,一个空格和文件的路径,类似于以下内容:

[PS 1] . C:\Users\Administrator\Desktop\YourPowerShellScript.ps1

然后你可以在命令提示符下调用该命令:

[PS 1] Disable-InternetExplorerESC

为什么你停止了“资源管理器”,但没有重新启动它? - wesm
2
@wes2020 我从某个地方偷了这个脚本,但我的假设是停止资源管理器只是“重新启动”它。如果停止了资源管理器,它将重新启动。 - Chris Hayes
在Windows Server 2012中,这对我不起作用。如果您在应用此操作后启动IE,则仍会出现受信任的弹出窗口;在服务器管理器中,信任功能显示为“关闭”,但如果单击配置,则管理员和用户复选框仍显示为“打开”。 - MaxVT
@MaxVT,根据此处提供的Rundll32 iesetup.dll设置,似乎已经解决了在Server 2012上的问题。 - russau

17
下面的修改已经添加了-Force参数,以避免任何确认。我在提示要确认是否要结束"explorer"进程时被提示要这样做。
function Disable-InternetExplorerESC {
    $AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
    $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
    Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 -Force
    Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 -Force
    Stop-Process -Name Explorer -Force
    Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green
}
function Enable-InternetExplorerESC {
    $AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
    $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
    Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 1 -Force
    Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 1 -Force
    Stop-Process -Name Explorer -Force
    Write-Host "IE Enhanced Security Configuration (ESC) has been enabled." -ForegroundColor Green
}
function Disable-UserAccessControl {
    Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Value 00000000 -Force
    Write-Host "User Access Control (UAC) has been disabled." -ForegroundColor Green    
}
Disable-UserAccessControl
Disable-InternetExplorerESC

1
第二个 Stop-Process -Name Explorer 上忘记加上 -Force 参数了吗? - JoePC
大家,只需导出您需要的注册表键,并在服务器管理器中切换启用和禁用设置,然后在PowerShell中使用.reg文件。不要让这变得太难了... - Patrick Burwell

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接