Collections:
Other Resources:
String Comparison in Windows PowerShell
How to compare two strings in Windows PowerShell?
✍: FYIcenter.com
Windows PowerShell supports the following string comparison operations:
-eq - Equal to -ne - Not equal to -gt - Greater than -ge - Greater than or equal to -lt - Less than -le - Less than or equal to -Like - Match with wildcard characters ? and * -NotLike - Not match with wildcard characters ? and * -Match - Match with regular expressions -NotMatch - Not match with regular expressions
Note that the above operations are case-insensitive. If you want to perform case-sensitive comparisons, you need to use the following comparison operations:
-ceq - Case-sensitive equal to -cne - Case-sensitive not equal to -cgt - Case-sensitive greater than -cge - Case-sensitive greater than or equal to -clt - Case-sensitive less than -cle - Case-sensitive less than or equal to -cLike - Case-sensitive match with wildcard characters ? and * -cNotLike - Case-sensitive not match with wildcard characters ? and * -cMatch - Case-sensitive match with regular expressions -cNotMatch - Case-sensitive not match with regular expressions
Here are some good examples of string comparison operations:
PS C:\fyicenter> "abc" -eq "Abc"
True
PS C:\fyicenter> "abc" -ceq "Abc"
False
PS C:\fyicenter> "abc" -lt "Abc"
False
PS C:\fyicenter> "abc" -clt "Abc"
True
PS C:\fyicenter> "anderson" -like "an*n"
True
PS C:\fyicenter> "anderson" -like "an????n"
False
PS C:\fyicenter> "anderson" -like "an?n"
False
PS C:\fyicenter> "anderson" -match "an.*n"
True
PS C:\fyicenter> "anderson" -NotMatch "an.*n"
False
⇒ String Replacement in Windows PowerShell
⇐ Expression Expansion in Strings in Windows PowerShell
2016-10-19, ∼3031🔥, 0💬
Popular Posts:
I am unable to copy data from my external hard-disk (NTFS). When I try to repair it from cmd using c...
What are the commonly used background processes on Windows systems? - Part II Continue from Part I ....
What is "@%SystemRoot%\ehome\ehs ched.exe,-101"in my Windows 7 service list? And how is "@%SystemRoo...
What files are stored in the "C:\Users\<userid >\AppData\Local\M icrosoft\Windows\Tempor. ..
How to remove BTTray.exe from startup program list? If you are not using any bluetooth devices, you ...