在 AWS 上的 Packer 中使用 PowerShell 禁用 Internet Explorer 增强的安全配置失败

Disabling Internet Explorer Enhanced Security Configuration using PowerShell in Packer on AWS Fails

在从最新的 AMI 构建 Windows Server 2016 实例时,我试图在 AWS 上的 Packer 中使用 PowerShell 禁用 Internet Explorer 增强的安全配置。

我在 PS 中从其中一个打包程序供应商调用以下函数:

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 -ErrorAction Continue
   Write-Host "IE Enhanced Security Configuration (ESC) has been disabled."
}

Disable-InternetExplorerESC

但是,Stop-Process -Name Explorer -Force 抛出以下错误:

Stop-Process : Cannot find a process with the name "Explorer". Verify the process name and call the cmdlet again.

远程进入服务器并打开服务器管理器并检查本地服务器设置显示 IE 增强安全配置为 "Off",但打开 Internet Explorer 仍显示设置为 "On" 并阻止下载。我尝试在进行更改后重新启动机器,但设置仍处于不明确状态。有没有我可以尝试的关闭 IE ESC 的不同方法,或者有其他方法可以在 Packer 中解决这个问题?

我能够使它与以下 PowerShell 脚本一起工作,该脚本被调用为打包程序构建脚本中具有提升权限的配置程序:

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
   Rundll32 iesetup.dll, IEHardenLMSettings
   Rundll32 iesetup.dll, IEHardenUser
   Rundll32 iesetup.dll, IEHardenAdmin
   Write-Host "IE Enhanced Security Configuration (ESC) has been disabled."
}

Disable-InternetExplorerESC

这是供应商的加壳程序片段:

{
   "type": "powershell",
   "scripts":[
   "{{ template_dir }}/scripts/Disable-InternetExplorerESC.ps1"
   ],
   "elevated_user": "{{user `local_admin`}}",
   "elevated_password": "{{user `local_admin_password`}}"
}

此外,这似乎只为 运行 脚本的提升用户禁用 IE ESC。

另一种方法(不使用 powershell)是使用服务器管理器关闭 IE 增强安全性。我发布这个答案是因为这是您搜索 "how to turn off IE Enhanced Security Configuration in AWS"

时弹出的第一个答案

打开服务器管理器 > 本地服务器 > 找到 IE 增强安全配置 > 单击 "On" 将其关闭(您可以仅为管理员或所有用户关闭它)