Skip to content

Instantly share code, notes, and snippets.

@rverrips
Created April 29, 2014 12:03
Show Gist options
  • Save rverrips/11398191 to your computer and use it in GitHub Desktop.
Save rverrips/11398191 to your computer and use it in GitHub Desktop.
Reset WSUS Auth Key on PC's that were mirrorred without running SYSPREP
@echo off
:: check_wsus.cmd
::
:: Logon script that checks if workstation token exists in wsus-check$
:: If it exists, simply exit, but if not, clears WINDOWSUPDATE registry keys.
::
:: Last updated by Roy Verrips ([email protected]) on 30th January 2014
::
set wsus-check=\\xxxxxxx-server-name-----\wsus-check$
if %computername%=="" goto :end
if exist %wsus-check%\%computername%.check goto :end
date /t >> %wsus-check%\%computername%.check
time /t >> %wsus-check%\%computername%.check
net stop wuauserv
if not exist C:\windows\system32\reg.exe copy $installpath\reg.exe c:\windows\system32
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v AccountDomainSid /f >> %wsus-check%\%computername%.check
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v PingID /f >> %wsus-check%\%computername%.check
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v SusClientId /f >> %wsus-check%\%computername%.check
net start wuauserv
wuauclt /resetauthorization /detectnow
goto :end
:end
echo ---------------------------------------------- >> %wsus-check%\machineids.txt
date /t >> %wsus-check%\machineids.txt
time /t >> %wsus-check%\machineids.txt
echo %computername% >> %wsus-check%\machineids.txt
@rverrips
Copy link
Author

Logon script that checks if workstation token exists in wsus-check$
If it exists, simply exit, but if not, clears WINDOWSUPDATE registry keys and does a reauth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment