[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

VBScript remove WINS in 2008 R2 domain

Posted on 2013-05-16
5
Medium Priority
?
355 Views
Last Modified: 2013-05-29
hello,

Is there a VBScript to remove the WINS entries for a list of servers and create a log as well? I have about 700 servers and need to remove all wins entries from them.

Thanks,
lal_gs
0
Comment
Question by:lal_gs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39171549
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39171556
to remove wins entries from all servers, add txt file with server names, one on each line and run the script with loop:
On Error Resume Next
strWINSPrimaryServer = "192.168.0.1"
strWINSSecondaryServer = "192.168.0.2"

Set fso = CreateObject("Scripting.FileSystemObject")
Set listFile = fso.OpenTextFile("list_server.txt")
do while not listFile.AtEndOfStream 
    strComputer =  listFile.ReadLine()

Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
WScript.Echo VbCrLf & "Host Name: " & strComputer & VbCrLf & _
 "  Attempting to set WINS primary and secondary servers ..."
 
For Each objNicConfig In colNicConfigs
  WScript.Echo VbCrLf & _
   "  Network Adapter " & objNicConfig.Index & VbCrLf & _
   "    " & objNicConfig.Description
  intSetWINSServer = objNicConfig.SetWINSServer(strWINSPrimaryServer, _
   strWINSSecondaryServer)
  If intSetWINSServer = 0 Then
    WScript.Echo "    Successfully set WINS servers."
  ElseIf intSetWINSServer = 1 Then
    WScript.Echo "    Successfully set WINS servers." & _
     VbCrLf & "    Must reboot."
  Else
    WScript.Echo "    Unable to set WINS servers."
  End If
Next
 
WScript.Echo VbCrLf & String(80, "-")
 
Set colNicConfigs = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
For Each objNicConfig In colNicConfigs
  WScript.Echo VbCrLf & _
   "  Network Adapter " & objNicConfig.Index & VbCrLf & _
   "    " & objNicConfig.Description
  WScript.Echo "    Primary WINS Server: " & objNicConfig.WINSPrimaryServer
  WScript.Echo "    Secondary WINS Server: " & _
   objNicConfig.WINSSecondaryServer
Next

loop

Open in new window

0
 

Author Comment

by:lal_gs
ID: 39191228
Thank you very much.

Is there a way to include a log file for this script so that we can find out on which servers this has been applied?

Thank you,

lal_gs
0
 
LVL 42

Accepted Solution

by:
Meir Rivkin earned 1500 total points
ID: 39191902
On Error Resume Next
strWINSPrimaryServer = "192.168.0.1"
strWINSSecondaryServer = "192.168.0.2"

Set fso = CreateObject("Scripting.FileSystemObject")
Set listFile = fso.OpenTextFile("list_server.txt")
Set logfile = fso.OpenTextFile("list_server.output.log", 2)
do while not listFile.AtEndOfStream 
    strComputer =  listFile.ReadLine()

Set objWMIService = GetObject("winmgmts:" _
 & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNicConfigs = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
WScript.Echo VbCrLf & "Host Name: " & strComputer & VbCrLf & _
 "  Attempting to set WINS primary and secondary servers ..."
 
For Each objNicConfig In colNicConfigs
  WScript.Echo VbCrLf & _
   "  Network Adapter " & objNicConfig.Index & VbCrLf & _
   "    " & objNicConfig.Description
  intSetWINSServer = objNicConfig.SetWINSServer(strWINSPrimaryServer, _
   strWINSSecondaryServer)
  If intSetWINSServer = 0 Then
  logfile.WriteLine objNicConfig & " Successfully set WINS servers."  
    WScript.Echo "    Successfully set WINS servers."
  ElseIf intSetWINSServer = 1 Then
  logfile.WriteLine objNicConfig & " Successfully set WINS servers, must reboot."  
    WScript.Echo "    Successfully set WINS servers." & _
     VbCrLf & "    Must reboot."
  Else
  logfile.WriteLine objNicConfig & " Unable to set WINS servers."  
    WScript.Echo "    Unable to set WINS servers."
  End If
Next
 logfile.Close
WScript.Echo VbCrLf & String(80, "-")
 
Set colNicConfigs = objWMIService.ExecQuery _
 ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
 
For Each objNicConfig In colNicConfigs
  WScript.Echo VbCrLf & _
   "  Network Adapter " & objNicConfig.Index & VbCrLf & _
   "    " & objNicConfig.Description
  WScript.Echo "    Primary WINS Server: " & objNicConfig.WINSPrimaryServer
  WScript.Echo "    Secondary WINS Server: " & _
   objNicConfig.WINSSecondaryServer
Next

loop

Open in new window

0
 

Author Closing Comment

by:lal_gs
ID: 39205175
Thank you very much for your prompt response.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question