sio*_*iom 3 powershell proxy internet-explorer
我的代理使用IE中LAN设置对话框中的"自动配置脚本"选项进行配置.为了切换这个设置,我编写了以下powershell脚本:
$proxyScript = 'http://example.com/files/wish.pac'
$debug = $TRUE
$currentValue = Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name AutoConfigURL -ErrorAction SilentlyContinue
if($debug)
{
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"
}
if([string]::IsNullOrEmpty($currentValue))
{
Write-Host "Proxy-AutoConfigURL is actually disabled"
Set-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name AutoConfigURL -value $proxyScript
Write-Host "Proxy-AutoConfigURL is enabled: " + $proxyScript
}
else
{
Write-Host "Proxy-AutoConfigURL is actually enabled"
Remove-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name AutoConfigURL
Write-Host "Proxy-AutoConfigURL is disabled."
}
if($debug)
{
Get-ItemProperty -Path HKCU:"Software\Microsoft\Windows\CurrentVersion\Internet Settings"
}
Run Code Online (Sandbox Code Playgroud)
在执行脚本后,IE的LAN设置对话框中的值已更改,因此脚本似乎有效.但它们似乎不适用于使用系统范围设置的IE和其他应用程序.只有当我单击LAN设置对话框中的"确定"按钮时,才会应用更新的值.
有没有办法使用PowerShell自动应用更改的设置?
您需要通知系统有关更新.检查我的代理模块,它不处理autoconfig,但原理是相同的
https://github.com/majkinetor/posh/blob/master/MM_Network/Update-Proxy.ps1
看refresh-system功能.
| 归档时间: |
|
| 查看次数: |
5508 次 |
| 最近记录: |