2008/11/26

Delete the WSUS Client ID's from registry by Logon script

CURRENT CONFIGURATION: Windows XP, 2003; WSUS 3; OS distribution method is cloning (imaging) of computers.
OBJECTIVE: Update all workstation and server trough WSUS
ISSUE: Computers override each other or not appear in WSUS console.
SOLUTION: When you clone (reimage) new computer from different either disk or clone image WSUS Client ID would be the same for either both or all recloned (reimaged) computers.
I've chosen VBS Login script approach to delete WSUS client ID's in registry.
The new WSUS ID's would be generated at "Automatic Updates" service start.
The computer would connect to WSUS server.
Please change MyCompanyName and MyDivisionName.
--- Start of code ---
'******************************************************************************
'   Author:  Vadims Zenins http://vadimszenins.blogspot.com
'   Version: 1.01
'   Date:    26/11/2009 18:18:44
'   Subroutine DeleteWSUSid
'   delete the WSUS Client ID's from the registry
'   and Restart service "Automatic Updates
'   Inputs - none
'   Call DeleteWSUSid()
'   WshShell.run "wuauclt.exe /resetauthorization /detectnow", 0, True
'******************************************************************************
Sub DeleteWSUSid()
  On Error resume next
' Stop service "Automatic Updates"
WshShell.run "net.exe stop wuauserv", 0, True

'Set the registry keypath that we are going to work with
strKeyPath = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate"
'Set the value name that we will use to create the registry marker
' (to determine if we've run the script before on this computer)
strKeyReportPath = "HKLM\SOFTWARE\MyCompanyName\MyDivisionName"
intValue = 1

If WSHShell.RegRead(strKeyReportPath & "\WSUSIDDeleted") <> "1" Then
strMessage = "Deleting WSUS IDs in registry: " & strKeyPath
'Show me a box for 3 sec.
WshShell.Popup strMessage,3
'Delete registry values
'strMessage =  "Deleting " & strKeyPath & "\AccountDomainSid"
'WshShell.Popup strMessage,2
WSHShell.RegDelete strKeyPath & "\AccountDomainSid"
'strMessage =  "Deleting " & strKeyPath & "\PingID"
'WshShell.Popup strMessage,2
WSHShell.RegDelete strKeyPath & "\PingID"
'strMessage =  "Deleting " & strKeyPath & "\SusClientId"
'WshShell.Popup strMessage,2
WSHShell.RegDelete strKeyPath & "\SusClientId"
'strMessage =  "Deleting " & strKeyPath & "\SusClientId"
'WshShell.Popup strMessage,2
WSHShell.RegDelete strKeyPath & "\SusClientIdValidation"

'Create Key in registry for report
WSHShell.RegWrite strKeyReportPath & "\WSUSIDDeleted", intValue, "REG_DWORD"
WSHShell.RegWrite strKeyReportPath & "\WSUSIDDeletedDate",Now

Wscript.Sleep 2000
' Start service "Automatic Updates"
WshShell.run "net.exe start wuauserv", 0, True

Else
End If

End Sub
'******************************************************************************

--- End of code ---

Download md5: 12d50a1db2af39c1a68884a107fccc43
LINKS: Delete the WSUS Client ID's from registry by Powershell script

1 комментарий:

Анонимный комментирует...

Why don't you just look for same key as your marker, ie if that specific sid exists, then reset.