How to convert datetime value to specific format for comparison
For get-date cmdlet, we have property called format , using that I can convert the date into specific format.
But for [datetime]::Now as it is c# static class, for that to convert the date time into specific format, you could use the toString method like below
$date = get-date -Format "yyyyMMddhhmm" – input value
$date2=([datetime]::Now).ToString("yyyyMMddhhmm") -comparing against time
if ( $date -eq $date2)