Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Setting Proxy Server based on connected network

Reply
 
Old 02-23-2007   #1 (permalink)
Sandip


 
 

Setting Proxy Server based on connected network

I work on my laptop from work and home. At work I am inside the company
intranet and browse internet through a Proxy Server. At home I use my own
cable ISP. Is there a powershell script to do that?


My System SpecsSystem Spec
Old 02-24-2007   #2 (permalink)
Sandip


 
 

RE: Setting Proxy Server based on connected network

Answering myself (a noob attempt):

if ((Get-ItemProperty -Path
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name
ProxyEnable | Select-Object ProxyEnable).ProxyEnable -eq 0)
{
Set-ItemProperty -Path
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name
ProxyEnable -Value 1
Write-Host "Proxy Enabled."
Get-ItemProperty -Path
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' |
Select-Object ProxyServer
}
else
{
Set-ItemProperty -Path
'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name
ProxyEnable -Value 0
Write-Host "Proxy Disabled."
}
if ((Get-Process -Name *iexplore*) -ne @())
{
Write-Host "Stopping browsers."
Stop-Process -Name iexplore -PassThru
Write-Host "Restarting a browser."
(New-Object -ComObject InternetExplorer.Application).Visible = $true
}
Start-Sleep -seconds 2

"Sandip" wrote:

> I work on my laptop from work and home. At work I am inside the company
> intranet and browse internet through a Proxy Server. At home I use my own
> cable ISP. Is there a powershell script to do that?
>

My System SpecsSystem Spec
Old 02-25-2007   #3 (permalink)
Jeffrey Snover [MSFT]


 
 

Re: Setting Proxy Server based on connected network

You might find this a little easier to use:
(get-ItemProperty 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet
Settings').ProxyEnable

"Sandip" <Sandip@discussions.microsoft.com> wrote in message
news:3121C6FE-9FE0-4564-AA1A-306E1468A763@microsoft.com...
> Answering myself (a noob attempt):
>
> if ((Get-ItemProperty -Path
> 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name
> ProxyEnable | Select-Object ProxyEnable).ProxyEnable -eq 0)
> {
> Set-ItemProperty -Path
> 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name
> ProxyEnable -Value 1
> Write-Host "Proxy Enabled."
> Get-ItemProperty -Path
> 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' |
> Select-Object ProxyServer
> }
> else
> {
> Set-ItemProperty -Path
> 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name
> ProxyEnable -Value 0
> Write-Host "Proxy Disabled."
> }
> if ((Get-Process -Name *iexplore*) -ne @())
> {
> Write-Host "Stopping browsers."
> Stop-Process -Name iexplore -PassThru
> Write-Host "Restarting a browser."
> (New-Object -ComObject InternetExplorer.Application).Visible = $true
> }
> Start-Sleep -seconds 2
>
> "Sandip" wrote:
>
>> I work on my laptop from work and home. At work I am inside the company
>> intranet and browse internet through a Proxy Server. At home I use my own
>> cable ISP. Is there a powershell script to do that?
>>


--
Jeffrey Snover [MSFT]
Windows PowerShell Architect
Microsoft Corporation
This posting is provided "AS IS" with no warranties, no confers rights.
Visit the Windows PowerShell Team blog at:
http://blogs.msdn.com/PowerShell
Visit the Windows PowerShell ScriptCenter at:
http://www.microsoft.com/technet/scr.../hubs/msh.mspx

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Very, very slow printing to network (server based) printer Vista print fax & scan
Re: Very, very slow printing to network (server based) printer Vista networking & sharing
Attempt to Network Vista Home on Domain Based Network (W2K -Server Vista networking & sharing
SMTP server setting in network connection properties Vista networking & sharing


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46