PowerShell – Configure IE proxy settings based on network name

Yet again one in the category of useful and practical scripts.
Because I’m a consultant I get around… and attach my laptop to every customers network. Since most of my customers are using proxy servers, I was starting to get a bit annoyed to set the proxy settings for the customer of that specific day in Internet Explorer.

And when I get home, I‘ll have to change those proxy settings again since I’m not using the same proxy configuration at my internal home network as my customer(s).

So… this morning I found some time to solve this irritation Emoticon met brede lach Of course by using PowerShell (well duh!) Verhitte emoticon

When I plug my laptop in a network it will find a network name… let’s say customer1.lan Glimlach So, based on a network name, I know which proxy settings to use, right?
Now what if I could use a simple script which compared the network name it found on the NIC to a CSV file and if a match is found correctly configures the appropriate proxy settings…now THAT would be useful Verhitte emoticon And since I want this script to be run at logon, I do not want anything to do with script parameters or something, just execute the darn thing Knipogende emoticon

Here’s the script (Set-Proxy.ps1) which configures the proxy by comparing the network name found by the local NIC to the ones in the CSV (CustomerNetworks.csv) file:

And here is an example of the content of the CSV file:


Note that the first values are the name of the customer. These values are not used in the script but I do find them useful since they make it easy to find the proxy settings when you need to find them Knipogende emoticon

Hope you find this one as useful as I have Verlegen emoticon


  1. Jimmy says:

    Thanks for the script. It works, but not when there are more then two entries in the CSV. The scripts sets the values for each entry in the CSV. But when the first is found, the proxy is set, then it reads the second line (foreach) and that network name is not found, the value is set to “0”. I am new to powershell, so it will take a while untill I have a solution. If you have one…. Please leave an update 🙂
    Thanks in advance.

  2. Jeff Wouters says:

    Hi Jimmy,

    Good catch, I’ve changed the script a little, it should work now.

  3. Jimmy says:

    Hey Jeff,
    saw your change there. Thanx. so it’s that easy? Thanx.

  4. Jeff Wouters says:

    Sure, you don’t have to be a rocket scientist to do PowerShell 😀

  5. Marc says:

    Goodmorning Jeff,

    I’m a newbie to powershell and your post is one of the reasons i want to start using powershell. Could you help me.. What parts of the script do i need to change to make it work for my environment. I already edited the .csv file.

    kind regards

  6. Jeff Wouters says:

    Hi Marc,
    The CSC file should be all you’ll need to change.
    If it’s not working, drop me an email at contact @ jeffwouters dot nl and I’ll help where I can.

  7. Akter Hossain says:

    Thanks for such wonderful script.
    How do I set my proxy according to my NIC IP?
    Say I have a IP block that is
    and another one is different.
    any clue?


  8. Jeff Wouters says:

    Sure, use the Get-NETIPAddress cmdlet and a switch statement.
    Something like this (fill in the appropriate actions in the switch):

    $NIC = Get-NetIPAddress -InterfaceIndex 7
    switch ($NIC.IPAddress) {
    {$_ -like “10.0.*” } { ‘10.0.x.x’ ; break }
    {$_ -like “192.168.*” } { ‘192.168.x.x’ ; break }

  9. Dylan Witte says:

    Nice Script, thanks a lot!
    For systems that change network connections while being logged on, you can configure a Scheduled Task to start the script that is triggered whenever networks change.
    Source NetworkProfile Event ID 10000 = connection established
    Source NetworkProfile event ID 10001 is connection disconnected

    Might be useful for others who do not want to run this script (only) during logon.

  10. George says:

    Looking for a script to retrieve if “Use a Proxy Server for you LAN” is enable or disabled from a list of computers on a CSV file. Also how to enable the checkbox or disabled it.

    Thank You,

  11. mark says:

    What about when connecting with VPN to another network?

Leave a Reply

Your email address will not be published. Required fields are marked *