Reputation: 11
I want to create a Powershell script to automatically tick the proxy settings "Automatically detect settings" and "Use automatic configuration script" as : Proxy Settings
So I found some tips, I am able to tick "Use automatic configuration script" with my proxy address with :
set-itemproperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -name AutoConfigURL -value 'proxy address'
And I am able to tick "Automatically detect settings" with
$key = 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Connections'
$data = (Get-ItemProperty -Path $key -Name DefaultConnectionSettings).DefaultConnectionSettings
$data[8] = 9
Set-ItemProperty -Path $key -Name DefaultConnectionSettings -Value $data
But If I try both like to put the two codes on the same script it doesn't work and only "Use automatic configuration script" is ticked.
I also saw that I can use the value 0d from : Source.
But when I tried that the output is "Error: Input string was not in a correct format."
Do you have any Idea on how I can do this ? Thank you.
Upvotes: 1
Views: 7968
Reputation: 21
[byte[]]$data = (Get-ItemProperty -Path $key -Name DefaultConnectionSettings).DefaultConnectionSettings
change to
[byte[]]$data = (Get-ItemProperty -Path $key).DefaultConnectionSettings
Overall, this is wonderful, great job Theo, thank you for sharing.
Todd
Upvotes: 2