concept operator in category powershell

appears as: operator, operators, The operators, operator, operators, n operator
Windows PowerShell in Action, Third Edition

This is an excerpt from Manning's book Windows PowerShell in Action, Third Edition.

the number 2 by itself is a complete expression, so the interpreter goes ahead and evaluates it. Likewise, + 2 is a complete expression and is also evaluated (+ in this case is treated as the unary plus operator). From this, you can see that if the newline comes after the + operator, the interpreter will treat the two lines as a single expression. If the newline comes before the + operator, it will treat the two lines as two individual expressions.

The goal of PowerShell is to enable you to get real work done. As in any language, expressions consist of operators and objects. The operators perform their operations on objects, giving you (hopefully) useful results. This chapter covers the set of basic operators in PowerShell and how they’re used in expressions. Without operators PowerShell can’t perform comparisons, arithmetic, logical operations, or a host of other activities. The operators we’re going to cover in this chapter are shown in figure 3.1.

Figure 3.1. Broad groups of operators we’ll cover in this chapter

Operators are normally classed as unary if they take a single operand and binary if they take two. The operators in this chapter are all binary. We’ll look at unary operators in chapter 4.

As you’ll see, PowerShell has lots of operators. PowerShell operators are typically more powerful than the corresponding operators in conventional languages such as C# or Java. If you invest the time to learn what the PowerShell operators are and how they work, in a single line of code you’ll be able to accomplish tasks that would normally take a significant amount of programming.

One of the characteristics that makes PowerShell operators so powerful is they’re polymorphic. This means they work on more than one type of object. Although this is generally true in other object-based languages, in those languages the type of the object defines the behavior of the operator.

PowerShell in Depth, Second Edition

This is an excerpt from Manning's book PowerShell in Depth, Second Edition.

In any computer language, operators provide a means of comparing and manipulating pieces of data. PowerShell’s no exception, offering a wide variety of operators for different tasks.

PS C:\Windows\System32\WindowsPowerShell\v1.0\en-US> Select-String -Pattern
   "shell" -SimpleMatch -Path *.txt -List
about_Aliases.help.txt:6:    PowerShell.
about_Arithmetic_Operators.help.txt:5:    Describes the operators that
perform arithmetic in Windows PowerShell.
about_Arrays.help.txt:9:    of the same type. Windows PowerShell supports
data elements, such as
about_Assignment_Operators.help.txt:13:    Windows PowerShell supports
the following assignment operators.

<display truncated for brevity>
sitemap

Unable to load book!

The book could not be loaded.

(try again in a couple of minutes)

manning.com homepage
test yourself with a liveTest