February 2017
Beginner
737 pages
15h 22m
English
PowerShell has two operators to compare two values to determine whether they are greater than (–gt) or less than (-lt) each other. This is not just limited to numbers, but also has the ability to compare dates and times as well. These are helpful in instances where you need to compare file sizes or modification dates on files.
A script that shows how to use the "less than" comparison operator would look like this:
$number1 = 10 $number2 = 20 If ($number1 –lt $number2) { Write-Host "Value $number1 is less than $number2" }
The output of this command is shown in the following screenshot:

In the preceding example, ...
Read now
Unlock full access