PowerShell Comparison Operators

Looking for a simple post that includes the powershell operators and her it is.

Less than =  -lt   Ex.  1 -lt 10

Greater than =  -gt   Ex. 10 -gt 1

Less than or equal = -le   Ex.  10 -le 10

Greather than or equal = -ge   Ex.    10 -ge 1

Equal = -eq   Ex.  1 -eq 1

To compare strigs you can use all the operators above if you want to validate case sensitive operators just at c to each of the operators

Equal = -ceq

Wild Card seaches use the -like operator.  * is for any characters that will match before the strings. ? is only one character after the string

Ex: “Hello”  – like “*ll?”  . In this example your comparison is true.

Subscribe For Latest Updates

Sign up for best of digital marketing, livestream and technology opinions on what matters to you.

Invalid email address
We promise not to spam you. You can unsubscribe at any time.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: