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

前端 未结 3 1960
天命终不由人
天命终不由人 2020-12-04 03:00

Today (2017-05-29) I am using PowerShell 5.0.10586.117 on Windows 7 Enterprise and run the following (shortened):

$dateOfLicense = \"2017-04-20\"
$dateOfToda         


        
3条回答
  •  再見小時候
    2020-12-04 03:33

    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"
    }
    

提交回复
热议问题