NetXMS Support Forum

English Support => General Support => Topic started by: dersonik on April 19, 2016, 11:28:15 AM

Title: Windows updates
Post by: dersonik on April 19, 2016, 11:28:15 AM
what this details means:


System update: last detect time = 1461028113
System update: last download time = 1460658737
System update: last install time = 1460630098


Windows server 2012
Title: Re: Windows updates
Post by: Victor Kirhenshtein on April 19, 2016, 04:34:43 PM
Hi,

it's time of last system update detection, download, and installation as UNIX time (seconds since epoch).

Best regards,
Victor
Title: Re: Windows updates
Post by: JRH on April 20, 2016, 02:17:27 AM
Hi dersonik

Run this in your transformation properties and it will return you the date and time from the unix time provided by the poll.

strftime("%Y-%m-%d %H:%M", $1)

Cheers
Title: Re: Windows updates
Post by: dersonik on April 20, 2016, 11:15:59 AM
Thank you very much
Title: Re: Windows updates
Post by: JRH on April 20, 2016, 12:03:21 PM
no Problem

I had to figure out the hard way :)
Title: Re: Windows updates
Post by: dersonik on April 21, 2016, 04:05:21 AM
any tips how grab the numbers of update to download?
Title: Re: Windows updates
Post by: jhonnyvey on April 23, 2016, 12:15:18 AM
Make a shellexec to cmd.
Use grep for windows and look in C:\windows\windowsupdate.log

If are you using windows 10:

Windows Update logs are now generated using ETW (Event Tracing for Windows).
Please run the Get-WindowsUpdateLog PowerShell command to convert ETW traces into a readable WindowsUpdate.log.
For more information, please visit http://go.microsoft.com/fwlink/?LinkId=518345
Title: Re: Windows updates
Post by: rainerh on March 19, 2017, 11:09:57 AM
I have a Windows Server 2016 but this DCI will not work: System.Update.LastInstallTime
Error: Cannot get current parameter value: Communication failure
Title: Re: Windows updates
Post by: Akira on May 14, 2017, 07:54:27 AM
2.0.8 still not working on 2016
Title: Re: Windows updates
Post by: rainerh on May 26, 2017, 02:32:52 PM
With new Version nxagent-2.1-RC1-x64 I will have the same error:
Cannot get current parameter value: Operation cannot be completed due to agent error
Title: Re: Windows updates
Post by: Tursiops on May 26, 2017, 03:41:41 PM
I am guessing that the System.Update.LastInstallTime is based on reading the Windows Update registry value, which Microsoft removed with Windows 10 and Server 2016, i.e. it won't work anymore.

The following PowerShell gives you the date of the last successful Windows Update installation (works for me, but knowing when my system last installed updates, the time appears to be in UTC):
$updateSearch = (New-Object -ComObject Microsoft.Update.Session ).CreateUpdateSearcher()
($updateSearch.QueryHistory(0,$updateSearch.GetTotalHistoryCount())| ?{$_.ResultCode -eq 2}|Sort-Object -Property Date -Descending).Date|Select -First 1


For some more background into, quoting "https://stackoverflow.com/questions/33732541/powershell-how-to-get-date-of-last-windows-update-install-or-at-least-checked-f":
$Session = New-Object -ComObject Microsoft.Update.Session
$Searcher = $Session.CreateUpdateSearcher()
$HistoryCount = $Searcher.GetTotalHistoryCount()
# http://msdn.microsoft.com/en-us/library/windows/desktop/aa386532%28v=vs.85%29.aspx
$Searcher.QueryHistory(0,$HistoryCount) | ForEach-Object {$_}


This will list all updates which the system tried to install, including a timestamp (which on my system appears to be UTC) and a result code.
Those translate to:
0 = Not Started
1 = In Progress
2 = Succeeded
3 = Succeeded With Errrors
4 = Failed
5 = Aborted


If a patch failed to install several times, it is supposedly listed several times as well. I cannot confirm that, as I have no failed patches in my list.
It also appears that the large cumulative updates like the Creators Update resets the contents of the list. Mine only goes back to said Creators Update.
Either way, with a bit of scripting you can return a few more things, like the number of unique patches which have failed to install.

I am not sure if the status 0 could be used to determine how many patches the system knows about that are not installed yet.