Hi,
I have to compare today's date +15d with date read from VM annotation.
Here is the code for today + 15d:
$Date = Get-Date -format "dd/MM/yyyy"
$Date = [datetime]$Date
$inTwoWeeks = $Date.AddDays(15)
here the output: 16/06/2016 00:00:00
here the code to get date in annotation:
$expiryDate = $vm | Get-Annotation -CustomAttribute "MACHINE_EXPIRY_DATE"
$expiryDate = [string]$expiryDate
$expiryDate = $expiryDate.replace(" ","")
$expiryDate = $expiryDate.Trim("MACHINE_EXPIRY_DATE:")
here the output: 31/12/2014
My question, how can I convert the second output to make a comparison with the first output?
Regards,
Fred
You can use $expiryDate = Get-Date $expiryDate to convert $expiryDate into a datetime object that you can compare to $inTwoWeeks.
You can use $expiryDate = Get-Date $expiryDate to convert $expiryDate into a datetime object that you can compare to $inTwoWeeks.
Hi RvdNieuwendijk,
Thanks a lot, that fixed my issue.
Regards,
Fred