variable

In Powershell what are the differences between       $text1=”Jack” and $text2=”jack”       and how to compare them in different ways.
arshavin KAsked:
Who is Participating?
 
QlemoConnect With a Mentor Batchelor, Developer and EE Topic AdvisorCommented:
No, the strings are not the same. Most comparision operators consider those strings the same by default, but that is something different.
0
 
aikimarkConnect With a Mentor Commented:
There are case-sensitive versions of the -match and -notmatch operators: -cmatch and -cnotmatch
0
 
aikimarkConnect With a Mentor Commented:
Likewise, there are case-sensitive versions of the simple value comparison operations (-eq, -le, -gt, etc.) by inserting a "c" after the "-" (-ceq, -cle, -cgt, etc.)
0
Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

 
aikimarkConnect With a Mentor Commented:
For more, invoke the help about_comparison_operators command in PS or visit the online documentation:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comparison_operators
1
 
arshavin KAuthor Commented:
So the answer is $text1=”Jack” and $text2=”jack” are the same and if we want to compare them those are the ways to compare:
There are case-sensitive versions of the simple value comparison operations (-eq, -le, -gt, etc.) by inserting a "c" after the "-" (-ceq, -cle, -cgt, cmatch, clike etc.)
0
 
arshavin KAuthor Commented:
those are the ways to compare them in different ways ?

Is it a good answer
0
 
arshavin KAuthor Commented:
MY QUESTION IS THIS
$text1=”Mike” and $text2=”mike”, compare them in different ways.

Could you please answer it for me
0
 
arshavin KAuthor Commented:
I wrote this For example, the case-sensitive version of -eq is -ceq. To make the case-insensitivity explicit
(-eq, -le, -gt, etc.) inserting a "c" after the "-" (-ceq, -cle, -cgt, cmatch, clike etc.)

"Mike" -eq "mike"
"Mike" -ceq "mike"
"Mike" -like "mike"
"Mike" -clike "mike"
"Mike" -contains "mike"
"Mike" -ccontains "mike"
0
 
QlemoConnect With a Mentor Batchelor, Developer and EE Topic AdvisorCommented:
The "c" variants are case-sensitive. To make the insensitivity exp!icit, you prefix with "i", like -imatch, which is the same as -match.
1
 
AlanConnect With a Mentor ConsultantCommented:
My view is that you should always use the explicit versions:

-cmatch
-imatch

Never use:

-match

However, I am inconsistent!

Alan.
0
 
AlanConsultantCommented:
Answered.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.