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

Sig*_*ard 4 powershell internet-explorer packer amazon-web-services windows-server-2016

当从最新的 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
Run Code Online (Sandbox Code Playgroud)

但是,会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 增强安全配置为“关闭”,但打开 Internet Explorer 仍将设置显示为“打开”并阻止下载。我尝试在进行更改后重新启动机器,但设置仍处于不明确状态。有没有我可以尝试的关闭 IE ESC 的不同方法或者在 Packer 中解决此问题的其他方法?

Sig*_*ard 5

我能够让它与以下 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
Run Code Online (Sandbox Code Playgroud)

以下是配置程序的打包程序片段:

{
   "type": "powershell",
   "scripts":[
   "{{ template_dir }}/scripts/Disable-InternetExplorerESC.ps1"
   ],
   "elevated_user": "{{user `local_admin`}}",
   "elevated_password": "{{user `local_admin_password`}}"
}
Run Code Online (Sandbox Code Playgroud)

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