none
Fetch most recent successful update and write to a text file in network path RRS feed

  • Question

  • Hi,

    I am executing the below script to fetch most recent successful update date from machines. I now want to redirect the output to a network path "\\abc\updatelist\". I want the filename to be the name of the computer and redirect the output to a text file to the given location. I want to execute the script using GPO as login script. Please help.

    -------------------------------------

    strComputer = "."

    Set objSession = CreateObject("Microsoft.Update.Session")

    Set objSearcher = objSession.CreateUpdateSearcher

    intHistoryCount = objSearcher.GetTotalHistoryCount

    'Set colHistory = objSearcher.QueryHistory(1, 1)

    Set colHistory = objSearcher.QueryHistory(1, intHistoryCount)

    ' Loop thru all Windows Updates and exit when find most recent successful update

    For Each objEntry in colHistory

        If objEntry.ResultCode = "2" Then

           'Wscript.Echo objEntry.ResultCode  

           Wscript.Echo objEntry.Date

           WScript.Quit

        End If

    Next

    • Moved by Bill_Stewart Friday, July 7, 2017 6:31 PM This is not "help me write a replacement for Windows update tool" forum
    Friday, May 19, 2017 1:49 PM

All replies

  • Get-Hotfix -ComputerName somepc | sort InstalledOn -descending | select -first 1 | Out-file \\abc\updatelist\updates.txt -append

    You don't want to do this in a logon script.

    I recommend getting MBSA or installing WSUS for patch management.


    \_(ツ)_/


    • Edited by jrv Friday, May 19, 2017 3:38 PM
    Friday, May 19, 2017 3:37 PM
  • Hi,

    I want to do this in a Logon script using the VB script. Can some one help ?

    thanks in advance.

    Monday, May 22, 2017 8:11 AM