...

Programming languages - Powershell

Back to Course

Lesson Description


Lession - #111 PowerShell-Operators


PowerShell gives a rich arrangement of operators to control variables. We can isolate all the powershell operators into the following groups −

  • Arithmetic Operators
  • Assignment Operators
  • Comparison Operators
  • Logical Operators
  • Redirectional Operators
  • Spilt and Join Operators
  • Type Operators
  • Unary Operators
The Arithmetic Operators
arithmetic operators operators are utilized in mathematical expressions similarly that they are utilized in variable based algebra. The following table lists the arithmetic operators−

Operator Description
+ (Addition>
Adds values on either side of the operator.
- (Subtraction>
Subtracts right-hand operand from left-hand operand.
* (Multiplication>
Multiplies values on either side of the operator.
/ (Division>
Divides left-hand operand by right-hand operand.
% (Modulus>
Divides left-hand operand by right-hand operand and returns remainder.


The Comparison Operators
Following are the assignment operators supported by PowerShell language −
Operator Descriptioneq
(equals>
Compares two values to be equivalent or not.
ne (not equals>
Compares two values to be not equal.
gt (greater than>
>
Compares first value to be more prominent than second one.
ge (greater than or equals to>
Compares first value to be more prominent than or equivalents to second one.
lt (less than>
Compares first value to be not exactly second one.
le (less than or equals to>
Compares first value to be not exactly or equivalents to second one.
The Assignment Operators
Following are the assignment operators supported by PowerShell language −
Operator Description
= Simple assignment operator. Assigns values from right side operands to left side operand.
+= Add AND assignment operator. It adds right operand to the left operand and assign the result to left operand.
-= Subtract AND assignment operator. It subtracts right operand from the left operand and assign the result to left operand.
The Logical Operators
The following table lists the logical operators −
Operator Description
AND (logical and>
Called Logical AND operator. On the off chance that both the operands are non-zero, the condition becomes true.
OR (logical or>
Called Logical OR Operator. On the off chance that any of the two operands are non-zero, the condition becomes true.
NOT (logical not>
Called Logical NOT Operator. Use to inverts the logical condition of its operand. In the event that a condition is valid then Logical NOT operator will make false.