【问题标题】:Disabling Internet Explorer Enhanced Security Configuration using PowerShell in Packer on AWS Fails在 AWS 上的 Packer 中使用 PowerShell 禁用 Internet Explorer 增强的安全配置失败
【发布时间】:2018-08-17 06:43:52
【问题描述】:

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

【问题讨论】:

    标签: powershell amazon-web-services internet-explorer windows-server-2016 packer


    【解决方案1】:

    我能够让它与以下 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
    

    这里是provisioner的packer sn-p:

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

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

    【讨论】:

      【解决方案2】:

      另一种方法(不使用 powershell)是使用服务器管理器关闭 IE 增强安全性。我发布此答案是因为这是您搜索“如何在 AWS 中关闭 IE 增强安全配置”时弹出的第一个答案

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

      【讨论】:

      • 当您希望某个东西通过 PowerShell 运行时,您如何“点击”它?
      • @StevenK7FAQ 请参阅附有答案的注释。这是弹出的第一个答案,当有人进行 googlesearch - 如何关闭 IE 增强安全配置。我们在这里帮助有需要的人。
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-26
      • 2013-06-30
      相关资源
      最近更新 更多