Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Server Migration > Re: Changing DNS Server IP

Reply
Thread Tools Display Modes

Re: Changing DNS Server IP

 
 
Ace Fekay [MCT]
Guest
Posts: n/a

 
      10-28-2009
> We have 2000 computers in our network all of which are using Static IP
> addresses. We are currently migrating to a new AD domain and want an
> automated way of changing the DNS Server IP address on these workstations.
> While i can use netsh command to achieve that i need to know the interface id
> or name to achieve that.
>
> So basically i am looking for a script which can take input of workstation
> ipaddress from a txt file and provide the interface name and id in an output
> file.


I'm not a scripting guru, but here's one example I got from a friend
years ago. Test it out on your own workstation. You can use the psexec
utility (from PSTools free from Microsoft) to remotely run it on all
machine, or set it in a logon script.

If there is only 1 NIC...

=======
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2")
'// Watch for line wrap here
Set colItems = objWMIService.ExecQuery("Select * from
Win32_NetworkAdapterConfiguration where IPEnabled = true")

'// Change to goDHCP() to set the machine to DHCP
goDHCP

Sub goDHCP()
For Each objItem In colItems

errEnable = objItem.EnableDHCP()
If errEnable = 0 Then
Wscript.Echo "DHCP has been enabled."
Else
Wscript.Echo "DHCP could not be enabled."
End If
Msgbox "setting DNS"
errDNS = objitem.SetDNSServerSearchOrder()
errDDNS = objItem.SetDynamicDNSRegistration
msgbox "DNS Set"
errRenew = objItem.RenewDHCPLease
msgbox "renew called"
If errRenew = 0 Then
Wscript.Echo "DHCP lease renewed."
Else
Wscript.Echo "DHCP lease could not be renewed." & err.number &
err.description
End If
Next
End Sub
======


Also...


======
The script below is to set all adapters to DHCP:
(from:
http://www.microsoft.com/technet/com.../scrnet03.mspx)

================================
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer &
"\root\cimv2") Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where
IPEnabled=TRUE") For Each objNetAdapter In colNetAdapters
arrDNSServers = Array()
objNetadapter.SetDNSServerSearchOrder(arrDNSServer s)
errEnable = objNetAdapter.EnableDHCP()
If errEnable = 0 Then
Wscript.Echo "DHCP has been enabled."
Else
Wscript.Echo "DHCP could not be enabled."
End If

Next
================================

--
Ace

This posting is provided "AS-IS" with no warranties or guarantees and
confers no rights.

Please reply back to the newsgroup or forum for collaboration benefit
among responding engineers, and to help others benefit from your
resolution.

Ace Fekay, MCT, MCITP EA, MCTS Windows 2008 & Exchange 2007, MCSE &
MCSA 2003/2000, MCSA Messaging 2003
Microsoft Certified Trainer

For urgent issues, please contact Microsoft PSS directly. Please check
http://support.microsoft.com for regional support phone numbers.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
migrate from windows server 2003 to windows server 2008R2 weedfrog Windows Server 9 12-15-2009 05:58 PM
Error not able to loging after upgrading domain controller Alexyy Active Directory 6 11-10-2009 07:09 AM
Re: New Server Transition question Ace Fekay [MCT] Windows Server 2 10-28-2009 05:39 AM
Re: Can I migrate/upgrade Windows Server 2008 32-bit to 64-bit? Meinolf Weber [MVP-DS] Server Migration 0 10-26-2009 11:37 AM
Re: 2003 migration to new 2003 server Meinolf Weber [MVP-DS] Server Migration 0 10-22-2009 08:48 AM



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 47 48 49 50 51 52 53 54 55 56 57 58 59