Book Image

Mastering Windows PowerShell Scripting

By : Brenton J.W. Blawat
Book Image

Mastering Windows PowerShell Scripting

By: Brenton J.W. Blawat

Overview of this book

Table of Contents (22 chapters)
Mastering Windows PowerShell Scripting
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Contains, like, and match operators


The -contains, -like, and -match operators are very similar in function. While they all compare data, they all have their own purpose in your scripts. Each of these operators are case-insensitive. This means that when you are searching for items using these operators, they will match all instances of the value in the expression. In instances where you need the search to be case-specific, you can append c in front of the operator to force case sensitivity. These would look like –ccontains, -clike, and –cmatch. To force case insensitivity, you can also append i in front of the operator. These would look like –icontains, -ilike, and –imatch.

Each of these operators also has an inverse operator that is formed by appending the word "not" in front of the operator. Examples of these operators include –notcontains, -notlike, and -notmatch. You may also append case sensitivity and case insensitivity to these operators.

The -contains operator looks for an exact match...