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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

aikimarkCommented:
There are case-sensitive versions of the -match and -notmatch operators: -cmatch and -cnotmatch
0
aikimarkCommented:
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
aikimarkCommented:
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
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

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
Qlemo"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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
Qlemo"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
AlanConsultantCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.