Quantcast
Channel: On-Site Tech Support » XP
Viewing all articles
Browse latest Browse all 11

Change DNS and WINS via Kaseya Script

$
0
0

Today we phased out an older server and promoted a newer one to DC. Typically this is no problem. Once it’s complete, reboot all the workstations and they will find the new DHCP/DNS server automatically. In our case, all o f the workstations were statically assigned. Since I didn’t want to have to touch 60+ workstations, I wrote this Kaseya Script to take care of it for me.

Script Name: Change DNS
Script Description: Sets primary DNS on Local Area Connection to X.X.X.X
Sets secondary DNS on Local Area Connection to X.X.X.X
Sets WINS on Local Area Connection to X.X.X.X

IF True
THEN
   Execute Shell Command
     Parameter 1 : netsh int ip set dns “Local Area Connection” static 192.168.0.242 index=1
     Parameter 2 : 1
         OS Type : 0
   Execute Shell Command
     Parameter 1 : netsh int ip set dns “Local Area Connection” static 192.168.0.240 index=2
     Parameter 2 : 1
         OS Type : 0
   Execute Shell Command
     Parameter 1 : netsh int ip set wins “Local Area Connection” static 192.168.0.242
     Parameter 2 : 1
         OS Type : 0
ELSE

All we needed to do was change the DNS and WINS servers, but if you need to either change them from static to DHCP, or change the static IP (one machine at a time please), here are 2 more scripts.

Script Name: Enable DHCP
Script Description: Enables DHCP on the local area connection

IF True
THEN
Execute Shell Command
Parameter 1 : netsh int ip set dns name = “Local Area Connection” source = dhcp
Parameter 2 : 1
OS Type : 0
Execute Shell Command
Parameter 1 : netsh int ip set address name = “Local Area Connection” source = dhcp
Parameter 2 : 1
OS Type : 0
Execute Shell Command
Parameter 1 : netsh int ip set wins name = “Local Area Connection” source = dhcp
Parameter 2 : 1
OS Type : 0
ELSE

Here is one to set static IP, subnet, gateway, DNS and WINS.

Script Name: Set Static IP
Script Description: Sets static IP, subnet and gateway on the local area connection.  The first address is your IP, the second is the subnet and the third is the gateway.
In this script it sets

IP=192.168.1.23
Subnet=255.255.255.0
Gateway=192.168.1.1
DNS=192.168.1.242
WINS=192.168.1.242

IF True
THEN
Execute Shell Command
Parameter 1 : netsh int ip set address “Local Area Connection” static 192.168.1.23 255.255.255.0 192.168.1.1
Parameter 2 : 1
OS Type : 0
Execute Shell Command
Parameter 1 : netsh int ip set dns “Local Area Connection” static 192.168.1.242 primary
Parameter 2 : 1
OS Type : 0
Execute Shell Command
Parameter 1 : netsh int ip set wins “Local Area Connection” static 192.168.0.240
Parameter 2 : 1
OS Type : 0
ELSE

Hope that helps.  Thanks for reading.


Viewing all articles
Browse latest Browse all 11

Trending Articles