Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Server Networking > script to change the static IP address

Reply
Thread Tools Display Modes

script to change the static IP address

 
 
Ezakial
Guest
Posts: n/a

 
      09-14-2009
I'm looking for a script which can change the static IP address such as Host
IP address, DNS IP, WINS IP, Gateway IP, & Subnet mask of remote Windows
Server 2k/2k3.

I have 300+ servers on which I have to remotely logon and update the above
mentioned details which is tedious task.

If anyone has a script to achieve this , I would be very thankful.

Thanks
 
Reply With Quote
 
 
 
 
Marcus Robinson
Guest
Posts: n/a

 
      09-14-2009
Take a look at http://msdn.microsoft.com/en-us/libr...17(VS.85).aspx

Also a quick Google for an example came back with
http://www.enterpriseitplanet.com/re...le.php/3082511

Perhaps can take something from them?

Marcus


--
Blog - http://www.techdiction.com
MR ICT Ltd - http://www.mrict.co.uk


"Ezakial" <> wrote in message
news:1E0DA830-5A9C-4833-AA27-...
> I'm looking for a script which can change the static IP address such as
> Host
> IP address, DNS IP, WINS IP, Gateway IP, & Subnet mask of remote Windows
> Server 2k/2k3.
>
> I have 300+ servers on which I have to remotely logon and update the above
> mentioned details which is tedious task.
>
> If anyone has a script to achieve this , I would be very thankful.
>
> Thanks


 
Reply With Quote
 
Ezakial
Guest
Posts: n/a

 
      09-14-2009

I found the script,

sNameSpace = "root/CIMV2"
sTargetClass = "Win32_NetworkAdapterConfiguration"
sClass = "Win32_NetworkAdapter"
sProperty1 = "AdapterType"
sValue1 = "Ethernet 802.3"
sProperty2 = "NetConnectionStatus"
iValue2 = 2

sComputer = "India"
sPriWINS = "1.2.3.4"
sSecWINS = "1.2.4.3"
aDNSServers = Array("1.2.2.1","1.2.3.5")
sDNSDomain = "swynk.com"
iNetBIOS = 1

sWQLQuery = "SELECT * FROM " & sClass & " WHERE " & sProperty1 & "=" &
Chr(34) & sValue1 & Chr(34) & _
" AND " & sProperty2 & "=" & iValue2

Set cInstances = GetObject("winmgmts:{impersonationLevel=impersonat e}//" & _
sComputer & "/" & sNameSpace).ExecQuery(sWQLQuery, "WQL")

For Each oInstance In cInstances
Set cAssociators = oInstance.Associators_(,sTargetClass)
For Each oAssociator In cAssociators
Set oMethod = oAssociator.Methods_("SetWINSServer")
Set oInParam = oMethod.InParameters.SpawnInstance_()
oInParam.WINSPrimaryServer = sPriWINS
oInParam.WINSSecondaryServer = sSecWINS
Set oOutParam = oAssociator.ExecMethod_("SetWINSServer", oInParam)

If oOutParam.returnValue = 0 Then
WScript.Echo UCase("SetWINSServer") & " method completed successfully"
Else
WScript.Echo UCase("SetWINSServer") & " method failed. Error Number " &
oOutParam.returnValue
End If

Set oMethod = oAssociator.Methods_("SetDNSServerSearchOrder")
Set oInParam = oMethod.InParameters.SpawnInstance_()
oInParam.DNSServerSearchOrder = aDNSServers
Set oOutParam = oAssociator.ExecMethod_("SetDNSServerSearchOrder", oInParam)

If oOutParam.returnValue = 0 Then
WScript.Echo UCase("SetDNSServerSearchOrder") & " method completed
successfully"
Else
WScript.Echo UCase("SetDNSServerSearchOrder") & " method failed. Error
Number " & oOutParam.returnValue
End If

Set oMethod = oAssociator.Methods_("SetDNSDomain")
Set oInParam = oMethod.InParameters.SpawnInstance_()
oInParam.DNSDomain = sDNSDomain
Set oOutParam = oAssociator.ExecMethod_("SetDNSDomain", oInParam)

If oOutParam.returnValue = 0 Then
WScript.Echo UCase("SetDNSDomain") & " method completed successfully"
Else
WScript.Echo UCase("SetDNSDomain") & " method failed. Error Number " &
oOutParam.returnValue
End If

Set oMethod = oAssociator.Methods_("SetTCPIPNetBIOS")
Set oInParam = oMethod.InParameters.SpawnInstance_()
oInParam.TcpipNetBIOSOptions = iNetBIOS
Set oOutParam = oAssociator.ExecMethod_("SetTCPIPNetBIOS", oInParam)

If oOutParam.returnValue = 0 Then
WScript.Echo UCase("SetTCPIPNetBIOS") & " method completed successfully"
Else
WScript.Echo UCase("SetTCPIPNetBIOS") & " method failed. Error Number " &
oOutParam.returnValue
End If

Next
Next



"Marcus Robinson" wrote:

> Take a look at http://msdn.microsoft.com/en-us/libr...17(VS.85).aspx
>
> Also a quick Google for an example came back with
> http://www.enterpriseitplanet.com/re...le.php/3082511
>
> Perhaps can take something from them?
>
> Marcus
>
>
> --
> Blog - http://www.techdiction.com
> MR ICT Ltd - http://www.mrict.co.uk
>
>
> "Ezakial" <> wrote in message
> news:1E0DA830-5A9C-4833-AA27-...
> > I'm looking for a script which can change the static IP address such as
> > Host
> > IP address, DNS IP, WINS IP, Gateway IP, & Subnet mask of remote Windows
> > Server 2k/2k3.
> >
> > I have 300+ servers on which I have to remotely logon and update the above
> > mentioned details which is tedious task.
> >
> > If anyone has a script to achieve this , I would be very thankful.
> >
> > Thanks

>
>

 
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
Static IP address Rex Windows Small Business Server 2 05-12-2008 02:43 AM
VBS Script error in Logon Script with AD change Webspeedway Active Directory 1 11-07-2006 01:55 AM
change from dynamic to static wan ip address D. Milton Windows Small Business Server 1 04-22-2006 12:24 AM
Using static IP address for OWA Y Windows Small Business Server 2 03-07-2005 11:47 PM
Static IP Address HELP !! Malcolm Cheyne Windows Small Business Server 39 07-13-2004 11:21 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