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

Comparison operator basics


When you are using comparison operators, you are creating expressions that evaluate to either True or False. In programming, this is known as Boolean. In the simplest form, you are asking PowerShell to evaluate similarities or dissimilarities between two items. Based on the findings from that expression, it will return True or False. When the whole expression returns False, PowerShell doesn't continue to process items in the statement. When the whole expression returns True, PowerShell will proceed forward into the statement and execute the code within the statement.

Of the many built-in variables that PowerShell has, there are two built-in Boolean variables. These two variables are $True and $False. When you call $True, it implies that the value is Boolean and is set to True. When you call $False, it implies that the value is Boolean and is set to False.

A script that shows how to use basic comparison operators would look like this:

$TrueVariable = $True
$FalseVariable...