DateTime subtraction not working in PowerShell – assignment vs. equality operator

You are assigning 14 to $TimeDifference. Instead you wan’t to compare the Days property using -le:

if ($TimeDifference.Days -le 14)
{
    Write-Host "test"
}

Leave a Comment