0

我正在尝试为每个用户的应用程序优化 IE11,以防不允许使用 GP。我想用一个脚本优化这些设置,这样每次收到请求时就不会花很多时间。

我试图创建一个首先测试注册表项路径的 powershell 脚本。之后,它应该提供一条消息以取消或继续,然后它应该更改值。

到目前为止,“测试路径”部分有效,但真正改变值不是。

$RegPaths = 
'HKCU:\Software\Microsoft\Internet Explorer\BrowserEmulation',
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap',
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1',
'HKCU:\Software\Microsoft\Internet Explorer\New Windows'

#Test-path $RegPaths

$RegEdit = 
{Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Internet Explorer\BrowserEmulation' -name IntranetCompatibilityMode -value 0},
{Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Internet Explorer\BrowserEmulation' -name MSCompatibilityModegpupd -value 0},
{Set-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap' -name AutoDetect -value 1},
{Set-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1' -name 1001 -value 0},
{Set-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1' -name 1004 -value 0},
{Set-ItemProperty -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1' -name 1201 -value 0},
{Set-ItemProperty -path 'HKCU:\Software\Microsoft\Internet Explorer\New Windows' -name PopupMgr -value 0}

#If (Test-path $RegPaths = True) 
#{write-host "Registry paths exist, continueing improving IE settings for ISCV client"}
#Foreach ($RegEdit) {if (Test-path $RegPaths -eq $True) {continue}}
#Else {write-host "Register path invalid or missing, canceling changes"}

If (( Test-Path $RegPaths) -eq $True) 
    {
        {write-host "Registry paths exist, continueing improving IE settings for ISCV client"}
        #{ForEach-object -process $RegEdit}
    Foreach ($RegEdit in $RegEdit)
        {start-job $RegEdit}
    }
Else
        {Write-Host " Path missing or invalid, cancel script"}

例如,-process 或 start-job 不会将值从 0 更改为 1,这是预期的。

谢谢!

更新 感谢您迄今为止的建议。我正在尝试并注意到只有“write-host”行和第一个 set-itemproperty 行实际上正在工作,之后什么也没发生,知道如何或为什么?

{write-host "Registry paths exist, continueing improving IE settings for 
client"}
    &{Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Internet 
Explorer\BrowserEmulation' -name IntranetCompatibilityMode -value 0}
    &{Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Internet 
Explorer\BrowserEmulation' -name MSCompatibilityModegpupd -value 0}
    &{Set-ItemProperty -Path 
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap' 
-name AutoDetect -value 1}
    &{Set-ItemProperty -Path 
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1' 
-name 1001 -value 0}
    &{Set-ItemProperty -Path 
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1' 
-name 1004 -value 0}
    &{Set-ItemProperty -Path 
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1' 
-name 1201 -value 0}
    &{Set-ItemProperty -path 'HKCU:\Software\Microsoft\Internet Explorer\New 
Windows' -name PopupMgr -value 0}

更新 上面的更新正在工作,我看起来不太好。谢谢!

4

1 回答 1

0

这段代码现在对我来说可以正常工作:

{write-host "Registry paths exist, continueing improving IE settings for 
client"}
    &{Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Internet 
Explorer\BrowserEmulation' -name IntranetCompatibilityMode -value 0}
    &{Set-ItemProperty -Path 'HKCU:\Software\Microsoft\Internet 
Explorer\BrowserEmulation' -name MSCompatibilityModegpupd -value 0}
    &{Set-ItemProperty -Path 
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap' 
-name AutoDetect -value 1}
    &{Set-ItemProperty -Path 
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1' 
-name 1001 -value 0}
    &{Set-ItemProperty -Path 
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1' 
-name 1004 -value 0}
    &{Set-ItemProperty -Path 
'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\Zones\1' 
-name 1201 -value 0}
    &{Set-ItemProperty -path 'HKCU:\Software\Microsoft\Internet Explorer\New 
Windows' -name PopupMgr -value 0}
于 2019-05-28T09:11:23.993 回答