Hi powershell gurus,
I am getting the data in the following format :
CLASS COUNT DESCRIPTION INITIAL_UPDATE LAST_UPDATE SEVERITY
Requirement is to have events picked only in the last 24hours from INITIAL_UPDATE. Any assistance is much appreciated.
then you can use a timespan to check how old the stamp is
New-TimeSpan -start ([datetime]'7/14/1979 11:24:23') -End (Get-Date) #Results @' Days : 13479 Hours : 11 Minutes : 56 Seconds : 50 Milliseconds : 81 Ticks : 11646286100815366 TotalDays : 13479.4978018696 TotalHours : 323507.947244871 TotalMinutes : 19410476.8346923 TotalSeconds : 1164628610.08154 TotalMilliseconds : 1164628610081.54 '@
You can then use the timespan with an if statement to check if it's within your desired range.
One slight problem.
The string has to be in US format – MM/DD/YYYY – if you use that approach.
25 December 2016 00:00:00
Converting a string to a DateTime object can be easy (if in US format) or a lot of work if in another format
What date format are you using?
You must be logged in to reply to this topic.