Fix Duplicate WSUS Ids

If you have an environment that that does not use SYSPREP you have a good chance that you will have duplicate WSUS IDs on your network and alot of system not patching properly.

These pair of scripts will query your WSUS DB and if the computer name does not match the WSUS id in the database it will reset the WSUS ID on the workstation.

wsusclientid.asp -> install on WSUS server

<%
susid = Request.QueryString("susid")
suscname = Request.QueryString("suscname")
connstring = "Driver={SQL Native Client};Server=localhost;Database=SUSDB;UID=wsusid;PWD=DBPASSWORD"
Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = connstring
objConn.Open

Set rs = objConn.execute ("select COUNT(ComputerTargetId) AS records from PUBLIC_VIEWS.vComputerTarget where (ComputerTargetID = '" & susid & "' and Name Like '" & suscname & "%');")

response.write rs("records")

rs.close

%>

susCLientID.vbs -> run as Startup Script

'stephen

'Check and correct duplicate sus client ids on the network

'this has a sister script on the wsus server to talk to.



'get susclientid

Set objRegistry = CreateObject("Wscript.shell")

Set WshNetwork = WScript.CreateObject("WScript.Network")

set oxmlhttp=createobject("msxml2.xmlhttp")



suscname = WshNetwork.ComputerName

susclientid = objRegistry.RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\SusClientID")



oxmlhttp.open "GET", "http://wsus.SERVER.local/wsusclientid.asp?susid=" & susclientid & "&suscname=" & suscname, false

oxmlhttp.send ""

response = oxmlhttp.responseText

if (response = 0 ) then

 objRegistry.regdelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\SusClientID"

 objRegistry.regdelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\SusClientIdValidation"

 WScript.Sleep 10000

 objRegistry.run "net stop wuauserv"

 WScript.Sleep 10000

 objRegistry.run "net start wuauserv"

 WScript.Sleep 10000

 objRegistry.run "wuauclt /resetauthorization /detectnow"

 WScript.Sleep 10000
 objRegistry.run "wuauclt /r /reportnow"
 WScript.Sleep 10000
end if


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.