Page 2 of 2

Re: catalog date

PostPosted: 20.03.2019, 23:56
by boco
The file modification date is no good indicator and can easily change, e. g. over FTP transfers, where the server doesn't support setting file times (will then become time of transfer). Plus, copying the catalog to a device with lower-precision timestamps (like FAT etc.) will modify it, too.

Re: catalog date

PostPosted: 26.03.2019, 15:04
by WSUSUpdateAdmin
Hi.

Dalai wrote:The following code would work a little bit better, but it's still far from reliable:
Code: Select all
echo Reminding catalog date...
for /F "tokens=4*" %%i in ('%SIGCHK_PATH% /accepteula -q -nobanner ..\client\wsus\wsusscn2.cab ^| %SystemRoot%\System32\findstr.exe /I "Signing"') do (
  if NOT "%%~j"=="" (
      echo %%j>..\client\catalogdate.txt
  ) ELSE (
     echo %%i>..\client\catalogdate.txt
  )
)

Batch is just so freaking limited...

Regards
Dalai


Nearly exactly took this one for r1025. :)

Thanks & regards
Torsten

Re: catalog date

PostPosted: 12.04.2019, 12:57
by hbuhrmester
Another option would be the creation date of the file package.xml.

If the file package.xml is pretty-printed to package-formatted.xml, then the CreationDate is found in line 2, as an attribute of the first element OfflineSyncPackage:

Code: Select all
<?xml version="1.0" encoding="utf-8"?>
<OfflineSyncPackage xmlns="http://schemas.microsoft.com/msus/2004/02/OfflineSync" MinimumClientVersion="5.8.0.2678" ProtocolVersion="1.0" PackageId="ec984487-b493-4c3a-bc8f-b27119c4e4aa" SourceId="cc56dcba-9026-4399-8535-7a3c9bed7086" CreationDate="2019-04-06T03:56:57Z" PackageVersion="1.1">


The CreationDate is in a well-defined format: ISO-8601 in UTC with date and time in seconds.

https://en.wikipedia.org/wiki/ISO_8601


Relevant xkcd:

https://xkcd.com/1179/

If we only need the date, we could use a simple combination of head, tail and grep:

Code: Select all
~/Projekte/wsusoffline/cache$ head -n 2 package-formatted.xml | tail -n 1 | grep -E --only-matching "[[:digit:]]{4}-[[:digit:]]{2}-[[:digit:]]{2}"
2019-04-06


Of course, this does not work with the original file package.xml, because this file doesn't have any line breaks, and the whole file is just one long line.

To get the full date and time, we could use a simple xslt-Transformation file, which extracts only this one element:

Code: Select all
<?xml version="1.0"?>
<!-- Author: H. Buhrmester, 2019 -->
<!-- Filename: get-creation-date.xsl -->
<!-- This file extracts one attribute: -->
<!-- Field 1: OfflineSyncPackage/@CreationDate -->
<!-- Note: This xslt transformation file extracts a single value,
     and therefore it doesn't need a for-each loop like the other xslt
     files. -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:__="http://schemas.microsoft.com/msus/2004/02/OfflineSync"
                version="1.0">
  <xsl:output omit-xml-declaration="yes" indent="no" method="text" />
  <xsl:template match="/">
    <xsl:value-of select="__:OfflineSyncPackage/@CreationDate" />
    <xsl:text>&#10;</xsl:text>
  </xsl:template>
</xsl:stylesheet>


Usage on Linux:

Code: Select all
~/Projekte/wsusoffline/cache$ xmlstarlet transform get-creation-date.xsl package.xml
2019-04-06T03:56:57Z