Announcement

Collapse
No announcement yet.

Script for WSUS detection

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Script for WSUS detection

    Hi,

    Having recently installed WSUS (Windows Software Update Services) I came against a (known) issue whereby clients were not appearing in the WSUS console because they were from imaged PCs which used the same client SID. WSUS would recognize one client, but because the SIDs were the same, it would not see others thereafter.

    This was resolved by placing a script I found into the Sysvol\Scripts which would run at startup and delete the values of 3 keys that apply to WSUS:

    --------------------------------------------------
    reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Win dowsUpdate /v AccountDomainSid /f
    reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Win dowsUpdate /v PingID /f
    reg delete HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Win dowsUpdate /v SusClientId /f
    cls
    @echo Triggering detection after resetting WSUS client identity
    net stop wuauserv
    net start wuauserv
    wuauclt /resetauthorization /detectnow
    --------------------------------------------------

    However, what I need is for the script to be modified so that the script is only run once, because each time it is run a new SID is created, WSUS thinks its a new client, so we get multiple clients appearing in the console.

    What I thought, was for the script to be modified so that -

    - the above file is modified to create a text file xxxyyyzzz.txt on the C:/ drive of the client
    - when the script is run again, if the above file exists, it exits without continuing with the remainder of the script

    Im afraid I have little scripting knowlege, so would appreciate any assistance you guys are able to provide in helping me achieve this.

  • #2
    Re: Script for WSUS detection

    I dont have enough time to give you full answer to this but i would suggest looking at using the compare function of REG (REG COMPARE /? for help info) - it will return 0 or 2 if two keys are the same or not. Look into that. Ill try and get a better response if no one else posts before i have more time to look at it.

    Hope it helps in the mean time
    Server 2000 MCP
    Development: ASP, ASP.Net, PHP, VB, VB.Net, MySQL, MSSQL - Check out my blog http://tonyyeb.blogspot.com

    ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

    Comment


    • #3
      Re: Script for WSUS detection

      Im not so sure that would work, as I want it to only run if a file doesnt exist on the C drive, so the file would act as the trigger.

      So it would - (where file xxxyyyzzz is a just a dummy file)

      First, check that a file XXXYYYZZZ exists on the C drive of the client.

      If the file does not exist, the above script needs to be run, and file XXXYYYZZZ would be copied into the root c:

      If the file does exist, then no further action needs to be taken.

      I hope this makes sense

      Comment


      • #4
        Re: Script for WSUS detection

        I once copied this script
        from: http://www.mcse.ms/archive302-2005-6-1698807.html ;
        Originally posted by Torgeir Bakken
        You can do it in a computer startup script (with a GPO) that runs as
        part of the boot up process (before the user logs in). It runs under
        the system context and has admin rights.

        The VBScript below will only delete the values once even if the script
        is run multiple times, by setting a registry marker.

        Code:
        '--------------------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<----------------------
        The scrips creates a 'marker' in the registry when it runs the first time.
        The second and all the nex times it will detect that marker and skip the cleaning of the SID.

        \Rem

        This posting is provided "AS IS" with no warranties, and confers no rights.

        __________________

        ** Remember to give credit where credit's due **
        and leave Reputation Points for meaningful posts

        Comment


        • #5
          Re: Script for WSUS detection

          Many thanks for this, I will try it out and post back with the results.

          Comment


          • #6
            Re: Script for WSUS detection

            How about something simple?... like:

            Code:
            IF NOT EXIST C:\WSUS_Clean_SID.txt (
            	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
            	net stop wuauserv
            	net start wuauserv
            	wuauclt /resetauthorization /detectnow
            	echo %date% >C:\WSUS_Clean_SID.txt
            )

            Comment


            • #7
              Re: Script for WSUS detection

              Looks like we have both VBS and batch files that will both do the job, nice job REMS and martin77
              Server 2000 MCP
              Development: ASP, ASP.Net, PHP, VB, VB.Net, MySQL, MSSQL - Check out my blog http://tonyyeb.blogspot.com

              ** Remember to give credit where credit is due and leave reputation points sigpic where appropriate **

              Comment


              • #8
                Re: Script for WSUS detection

                great batch Martin, nicely done

                Although I personally prefer keeping all the information together in the same registrykey, it makes it easer when you would like to check things from remote later on.

                And, a file in the root is more visible, and is not attached so it can be easier deleted by mistake by an other Administrator. But... on the otherhand, when the 'flag or marker' it is easily visible, you may not forget to delete it first before you planned to create a 'new Image' of that computer!

                \Rem

                This posting is provided "AS IS" with no warranties, and confers no rights.

                __________________

                ** Remember to give credit where credit's due **
                and leave Reputation Points for meaningful posts

                Comment


                • #9
                  Re: Script for WSUS detection

                  thanks.
                  I couldn't agree more.

                  Comment

                  Working...
                  X