在Windows Server上为所有用户和系统帐户设置代理

我们正在尝试为Azure部署ARM模板。 我们希望为所有用户和系统帐户设置代理。 但我们无法做到这一点。 当我们使用这个PowerShell脚本,当前用户有一个代理,但不是系统帐户。 有什么build议么?

<# .Synopsis This function will set the proxy settings provided as input to the cmdlet. .Description This function will set the proxy server and (optinal) Automatic configuration script. .Parameter ProxyServer This parameter is set as the proxy for the system. Data from. This parameter is Mandatory .Example Setting proxy information Set-InternetProxy -proxy "proxy:7890" .Example Setting proxy information and (optinal) Automatic Configuration Script Set-InternetProxy -proxy "proxy:7890" -acs "http://proxy:7892" #> #[CmdletBinding()] Param( [Parameter(Mandatory=$True,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] [String[]]$Proxy, [Parameter(Mandatory=$False,ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] [AllowEmptyString()] [String[]]$acs ) Begin { $regKey="HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" } Process { Set-ItemProperty -path $regKey ProxyEnable -value 1 Set-ItemProperty -path $regKey ProxyServer -value $proxy if($acs) { Set-ItemProperty -path $regKey AutoConfigURL -Value $acs } #$obj = Get-ItemProperty -Path Registry::”HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" #Set-ItemProperty -Path Registry::”HKEY_USERS\S-1-5-18\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" -Name DefaultConnectionSettings -Value $obj.DefaultConnectionSettings #Set-ItemProperty -Path Registry::”HKEY_USERS\S-1-5-18\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections" -Name SavedLegacySettings -Value $obj.SavedLegacySettings #$obj = Get-ItemProperty -Path Registry::”HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings" #Set-ItemProperty -Path Registry::”HKEY_USERS\S-1-5-18\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name ProxyEnable -Value $obj.ProxyEnable #Set-ItemProperty -Path Registry::”HKEY_USERS\S-1-5-18\Software\Microsoft\Windows\CurrentVersion\Internet Settings" -Name Proxyserver -Value $obj.Proxyserver } End { Write-Output "Proxy is now enabled" Write-Output "Proxy Server : $proxy" if ($acs) { Write-Output "Automatic Configuration Script : $acs" } else { Write-Output "Automatic Configuration Script : Not Defined" } } 

根据上面的脚本,你已经把你需要的钥匙弄出来了。

你正在设置错误的键。 试试这个:

 Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections\DefaultConnectionSettings 

在这个关键:

 HKEY_USERS\S-1-5-18 

而你应该是金的!