Link to home
Start Free TrialLog in
Avatar of Thomas N
Thomas NFlag for United States of America

asked on

script for removing wsus client registry key

I have a domain that has very few machines reporting to WSUS and thats because I believe the tech here created an image from an old image. Long story short I need to delete the registry keys (pingid,accoundomansid,susclienid) so that they can report to the server. I need to run it in AD as a startup script, I have over 3k machines on the network. I found the script below but not sure its working, can anyone assist?

'--------------------8<----------------------
Set oShell = CreateObject("WScript.Shell")

sRegKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate"

' suppress error in case values does not exist
On Error Resume Next

' check for marker
sIDDeleted = oShell.RegRead( sRegKey & "\IDDeleted")

' to be sure values is only deleted once, test on marker
If sIDDeleted <> "yes" Then
   ' delete values
   oShell.RegDelete sRegKey & "\AccountDomainSid"
   oShell.RegDelete sRegKey & "\PingID"
   oShell.RegDelete sRegKey & "\SusClientId"

   ' Stop and start the Automatic updates service
   oShell.Run "%SystemRoot%\system32\net.exe stop wuauserv", 0, True
   oShell.Run "%SystemRoot%\system32\net.exe start wuauserv", 0, True

   ' Run wuauclt.exe with resetauthorization
   sCmd = "%SystemRoot%\system32\wuauclt.exe /resetauthorization /detectnow"
   oShell.Run sCmd, 0, True

   ' create marker
   oShell.RegWrite sRegKey & "\IDDeleted", "yes"
End If
'--------------------8<----------------------
Avatar of Don
Don
Flag of United States of America image

I use a .bat for this
 

%Windir%\system32\net.exe stop bits 
%Windir%\system32\net.exe stop wuauserv
 
reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v AccountDomainSid /f
reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v PingID /f
reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v SusClientId /f
reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate /v SusClientValidation /f
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v LastWaitTimeout /f
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v DetectionStartTime /f
reg delete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v NextDetectionTime /f
 
 
 
 
if exist %Windir%\system32\atl.dll %Windir%\system32\regsvr32.exe /s %Windir%\system32\atl.dll  
if exist %Windir%\system32\jscript.dll %Windir%\system32\regsvr32.exe /s %Windir%\system32\jscript.dll 
if exist %Windir%\system32\softpub.dll  %Windir%\system32\regsvr32.exe /s %Windir%\system32\softpub.dll  
if exist %Windir%\system32\wuapi.dll %Windir%\system32\regsvr32.exe /s %Windir%\system32\wuapi.dll 
if exist %Windir%\system32\wuaueng.dll  %Windir%\system32\regsvr32.exe /s %Windir%\system32\wuaueng.dll  
if exist %Windir%\system32\wuaueng1.dll  %Windir%\system32\regsvr32.exe /s %Windir%\system32\wuaueng1.dll  
if exist %Windir%\system32\wucltui.dll  %Windir%\system32\regsvr32.exe /s %Windir%\system32\wucltui.dll  
if exist %Windir%\system32\wups.dll  %Windir%\system32\regsvr32.exe /s %Windir%\system32\wups.dll  
if exist %Windir%\system32\wups2.dll  %Windir%\system32\regsvr32.exe /s %Windir%\system32\wups2.dll  
if exist %Windir%\system32\wuweb.dll  %Windir%\system32\regsvr32.exe /s %Windir%\system32\wuweb.dll  
if exist %windir%\system32\iuengine.dll %windir%\system32\regsvr32.exe /s iuengine.dll
if exist %windir%\system32\wuauserv.dll %windir%\system32\regsvr32.exe /s wuauserv.dll
if exist %windir%\system32\cdm.dll %windir%\system32\regsvr32.exe /s cdm.dll
if exist %windir%\system32\msxml2r.dll %windir%\system32\regsvr32.exe /s msxml2r.dll
if exist %windir%\system32\msxml3r.dll %windir%\system32\regsvr32.exe /s msxml3r.dll
if exist %windir%\system32\msxml.dll  %windir%\system32\regsvr32.exe /s msxml.dll
if exist %windir%\system32\msxml3.dll %windir%\system32\regsvr32.exe /s msxml3.dll
if exist %windir%\system32\msxmlr.dll %windir%\system32\regsvr32.exe /s msxmlr.dll
if exist %windir%\system32\msxml2.dll %windir%\system32\regsvr32.exe /s msxml2.dll
if exist %windir%\system32\qmgr.dll %windir%\system32\regsvr32.exe /s qmgr.dll
if exist %windir%\system32\qmgrprxy.dll %windir%\system32\regsvr32.exe /s qmgrprxy.dll
if exist %windir%\system32\iuctl.dll %windir%\system32\regsvr32.exe /s iuctl.dll
 
del C:\Windows\WindowsUpdate.log /S /Q
rd /s /q %windir%\softwareDistribution
sleep 5
%Windir%\system32\net.exe start bits 
%Windir%\system32\net.exe start wuauserv 
 
 
sc sdset wuauserv D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)
 
 
sc sdset bits D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)
 
wuauclt.exe /resetauthorization
wuauclt.exe /detectnow 
wuauclt.exe /reportnow
 
 
 
exit /B 0 

Open in new window

Avatar of roseroj
roseroj

Here is what we use.  However, you might have to remove the "echo" portions if you do not want it to be interactive.
@echo off
echo Stopping Update Agent...
net stop wuauserv
echo Deleting Existing WSUS Cache...
echo.
del /s /q %systemroot%\SoftwareDistribution
echo.
echo Starting Update Agent...
net start wuauserv
pause
echo.
Echo Attaching to WSUS...
wuauclt /detectnow
wuauclt /reportnow

Open in new window

Please note that the above is simply a batch file.
roseroj
Your script will be of no use for the duplicate SID issue.
Avatar of Thomas N

ASKER

dstewartjr: I can add your script as a GPO startup script and it should work? Have you done it? Thanks
Yes, I have. I just remove it after all is well. If this doesnt fix it for you post a windowsupdate.log and we can further investigate.
Thanks I will give it a try now and will return with the results. I do notice that there is only the susclientid and susclientvalidation key. There is no pingid or accountdomainsid. I wonder why that would be?
The susclientid and susclientvalidation key are the only two required, this is all that shows in our environment as well.
hmm...when I run the script manually I see the susclientid change. But when I add it to the GPO as a script it does not work.

I added it to the Computer configuration | Scripts | Startup - I look at the advanced system information on the machine and it says it loads the GPO and the script but for some reason I check the registry and its the same. I have gpupdated/forced it a few times and restarted the computer. Any sugggestions?
you could use psexec \\* -c -f -s \\server\share\fixwsus.bat
 
Just tested this command, it will go thru your whole domain
Only errors I am getting is "sleep command not recognized" , also bat file exited with error code 0.   Also do you suggest running this during business hours? Do you think it causes alot of network traffic.
Im going to run it when I leave today so it runs over the weekend. I will give an update on monday. Thanks dstewartjr for your help
ASKER CERTIFIED SOLUTION
Avatar of Don
Don
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ran over the weekend and it worked great. Now most if not all machines reporting to WSUS.
used the batch file from dstewartjr - excellent !!!