Settings

Log In

Tools/Scripts

When you’re in the consulting business, you travel a lot between companies. That what I consider the beautiful part of the job. Downside is that every company has it’s own policy for Internet usage. A lot of companies regulate their internet access through so called proxy servers. When you visit a lot of companies you have to change the internet settings multiple times a day to match the desired settings for that company. Therefore I wrote a powershell script that detects the DNS suffix of the company you’re at and matches the proxy settings according to the configured settings read from a XML file.

What does the script do:

Change Proxy Server settings for Internet Explorer and Chrome

Add Proxy Exceptions to bypass the proxy

When connected to multiple networks a known location takes presence

When a location is not known, the configuration defaults to “Direct Connection”

Notifies you which settings are used.

What the script does NOT do:

Detect networks based on IP Address (Never will, too general way of checking)

Change Proxy settings for FireFox (#1 on my wishlist)

Detect network changes dynamically.

Installation/Configuration

Copy the PS1 and XML to a convinient location (eg. C:\Windows). Configure the XML file for use with proxy servers. Each location must be in its own <Sites> node.

<Name> The name for your location is must be in the Name node.<DNSDomain> The DNS Domain that should be checked is in this node<ProxyServer> In this node you enter the proxy server name<ProxyPort> In this node you enter the proxy port that should be used<ProxyOverRide> All exceptions that should bypass the proxy server are entered in this node, each exception should be separated with a semi column.

Each location should look like the above example, you can append multiple sites to the <Global> node. I’ve tested the script on Windows 7 (x64) but it should work on Windows XP as well. to hide the Powershell command-box you can start the powershell script with:

One of the first powershell scripts I wanted to share is a script that checks your WAN ip and notifies you by e-mail when it changes.

Background:

I’ve used to sign up with a dynamic DNS provider but my router stopped updating my ip address to that DynDNS provider. After a while I received an e-mail that my host was being deleted from the database if I did not take action. A few e-mail later I decided to say goodbye to that DynDNS provider because my IP-Address does not change that much at all (I still have the same address as a year ago). So I wrote a script that checks the IP address of your FQDN and uses the automation page of WhatisMyIP.com to read you current WAN ip address and sends you an e-mail when it has changed.

Yesterday I was asked to implement a time-out on active citrix sessions. The purpose for the script was to limit the maximum active session time for the user. The HKLM\System\CurrentControlSet\Control\Terminal Server\WinStations\ICA-TCP\MaxActiveSession registry key was not flexible enough and I couldn’t find a ready made solution. I decided to develop my own script based on information in the XenApp Management SDK and on CDN. After some time of scripting I found the following script working and flexible enough to meet the demands of the customer. Basically you schedule the command with the following parameter “cscript <filename.wsf> min <time-out in minutes>”

XX minutes before the session if logged off the user is send an message, the XX minutes is defined by the WarnThreshold value in the script. the Message can be customized by editing the strMsg + strTitle value.

The script can be easily adjusted to be used for a flexible Idle Time-out . the only property that has to be adjusted is Session.LogonTime into Session.LastInputTime

All warnings are logged to a logfile which you can set in the script. Make sure the account used for running the script is a XenApp Administrator.