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_8601Relevant 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> </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