Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Arithmetic Operators


Arithmetic operators are used to perform mathematical calculations in PowerShell. These operators include:

  1. Addition (+): Adds two values together. For example, $a + $b adds the value of $a and $b.

  2. Subtraction (-): Subtracts one value from another. For example, $a - $b subtracts the value of $b from $a.

  3. Multiplication (*): Multiplies two values together. For example, $a * $b multiplies the value of $a and $b.

  4. Division (/): Divides one value by another. For example, $a / $b divides the value of $a by $b.

  5. Modulus (%): Returns the remainder after dividing one value by another. For example, $a % $b returns the remainder after dividing the value of $a by $b.

These arithmetic operators can be used with numerical values or variables that contain numerical values. They can also be combined with assignment operators to modify the value of a variable. For example, $a += $b adds the value of $b to $a and stores the result in $a.

Arithmetic operators are an essential part of performing mathematical calculations in PowerShell, and they can be used in combination with other operators and cmdlets to create powerful scripts for data analysis, reporting, and more.