I want to retrieve the warranty dates of my DELL server devices and compare them to the current date, then my powershell script send the result to my CENTREON (less than 90 days Warning, less than 30 days CRITICAL…etc …)
the script works well and I get the information “warranty date” in a variable.
unfortunately I do not know how to process the information I get, I start powershell and I do not understand how to convert my result format date and then make the comparison with the date of the day.
Do you have some tips to bring me to help me in my research?
I’m not able to run the code as I don’t have a Dell, so I can’t see what data you’re actually getting back. If you could share some of that, it’d be easier to offer useful suggestions.
Generally, if you’re getting dates as a string, you want to convert them to a DateTime:
[DateTime]$datetime = "03/04/2018"
As an example. Get-Date also returns DateTimes:
$Now = Get-Date
And then you can compare using -gt (greater than) and -lt, or other comparison operators. Those all work against dates.