Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell -like, -gt, etc

Tags:

powershell

I just started learning Powershell. Can somebody please explain to me or give me the exact name for these: -gt, -like, etc. I just tried to Google them but can't find the proper link for explanation.

Thank you very much!

like image 969
hk_03 Avatar asked Jul 03 '26 23:07

hk_03


1 Answers

These are called comparsion operators.

-gt

Greater than.

Example:

PS C:\> 8 -gt 6
True

PS C:\> 7, 8, 9 -gt 8
9

-Like

Match using the wildcard character (*).

Example:

PS C:\> "Windows PowerShell" -like "*shell"
True

PS C:\> "Windows PowerShell", "Server" -like "*shell"
Windows PowerShell

A Google search for Powershell comparison operators finds the Powershell documentation page: https://technet.microsoft.com/en-us/library/hh847759.aspx

Windows PowerShell includes the following comparison operators:

-eq
-ne
-gt
-ge
-lt
-le
-Like
-NotLike
-Match
-NotMatch
-Contains
-NotContains
-In
-NotIn
-Replace

By default, all comparison operators are case-insensitive. To make a comparison operator case-sensitive, precede the operator name with a "c". For example, the case-sensitive version of "-eq" is "-ceq". To make the case-insensitivity explicit, precede the operator with an "i". For example, the explicitly case-insensitive version of "-eq" is "-ieq".

like image 129
Ma3x Avatar answered Jul 05 '26 16:07

Ma3x