{"id":75841,"date":"2016-01-10T03:59:00","date_gmt":"2016-01-10T03:59:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2016\/01\/10\/powertip-use-powershell-to-perform-case-sensitive-comparison\/"},"modified":"2019-02-18T09:20:20","modified_gmt":"2019-02-18T16:20:20","slug":"powertip-use-powershell-to-perform-case-sensitive-comparison","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/powertip-use-powershell-to-perform-case-sensitive-comparison\/","title":{"rendered":"PowerTip: Use PowerShell to Perform Case-Sensitive Comparison"},"content":{"rendered":"<p><b>Summary<\/b>: Learn how to perform a case-sensitive comparison in Windows PowerShell.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/q-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Question\" \/>&nbsp;I need to compare two strings while taking case sensitivity into account. I try using&nbsp;<b>-eq<\/b>, but it does not work. <br \/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; How can I use Windows PowerShell to perform a case-sensitive comparison?<\/p>\n<p style=\"margin-left:30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/a-for-powertip.jpg\" alt=\"Hey, Scripting Guy! Answer\" \/>&nbsp;Use the&nbsp;<b>-ceq<\/b>&nbsp;operator instead of&nbsp;<b>-eq<\/b>. Here are two examples that compare the results of&nbsp;<b>-eq<\/b>&nbsp;and&nbsp;<b>-ceq<\/b>:<\/p>\n<p style=\"margin-left:120px\">PS C:\\&gt; &#039;scripting guys&#039; -eq &#039;Scripting Guys&#039;<\/p>\n<p style=\"margin-left:120px\">True<\/p>\n<p style=\"margin-left:120px\">PS C:\\&gt; &#039;scripting guys&#039; -ceq &#039;Scripting Guys&#039;<\/p>\n<p style=\"margin-left:120px\">False<\/p>\n<p style=\"margin-left:120px\">PS C:\\&gt;<\/p>\n<p style=\"margin-left:30px\"><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/7610.Dr.ScriptoForTips.jpg\" alt=\" \" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Learn how to perform a case-sensitive comparison in Windows PowerShell. &nbsp;I need to compare two strings while taking case sensitivity into account. I try using&nbsp;-eq, but it does not work. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; How can I use Windows PowerShell to perform a case-sensitive comparison? &nbsp;Use the&nbsp;-ceq&nbsp;operator instead of&nbsp;-eq. Here are two [&hellip;]<\/p>\n","protected":false},"author":597,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[356,3,45],"class_list":["post-75841","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-powertip","tag-scripting-guy","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Learn how to perform a case-sensitive comparison in Windows PowerShell. &nbsp;I need to compare two strings while taking case sensitivity into account. I try using&nbsp;-eq, but it does not work. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; How can I use Windows PowerShell to perform a case-sensitive comparison? &nbsp;Use the&nbsp;-ceq&nbsp;operator instead of&nbsp;-eq. Here are two [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/75841","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/597"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=75841"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/75841\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=75841"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=75841"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=75841"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}