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 ...)
I found a script "GetDellWarrantyInfo.ps1"
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?
in advance a thank you to those who can help me.
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.
thank-s for your help 🙂
the script for
# codes de sortie
# "OK" exit 0
# version de powershell V3
$servicetag = $args
# Get Data
# Extract Warranty Info
# Read first entry if available
$tdiff = New-TimeSpan -Start $lastdate -End $date
IF( $Nb_jour -gt "60" )
IF( $Nb_jour -gt "0" )
write-host -foregroundcolor red "$name , hors garantie depuis $NB_jour jours , service TAG $servicetag" ;
You must be logged in to reply to this topic.