gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 23:54:19 26 4
gpt4 key购买 nike

当从他们最新的 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:找不到名为“Explorer”的进程。验证进程名称并再次调用 cmdlet。

远程进入服务器并打开服务器管理器并检查本地服务器设置显示 IE 增强安全配置为“关闭”,但打开 Internet Explorer 仍显示设置为“打开”并阻止下载。我尝试在进行更改后重新启动机器,但设置仍处于不明确状态。有没有我可以尝试的关闭 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 - 在 AWS 上的 Packer 中使用 PowerShell 禁用 Internet Explorer 增强的安全配置失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49181142/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com