Often you may want to raise one number to the power of another number in PowerShell.
You can use the [Math]::Pow command to do so.
The following examples show how to use this command in practice.
Example 1: Use Exponents with One Number in PowerShell
Suppose that we would like to raise 5 to the power of 3 in PowerShell.
We should receive the following result: 53 = 125
We can use the following syntax in PowerShell to perform this operation:
[Math]::Pow(5, 3)
The following screenshot shows how to use this syntax in practice:

We can see that this returns 125, which is the correct result.
Example 2: Use Exponents with an Array of Numbers in PowerShell
Suppose that we would like to raise the value of each number in an array to the power of 3 in PowerShell.
We can use the following syntax to do so :
$my_array = @(1, 2, 3, 4, 5)
$my_array | % { [Math]::Pow($_, 3) }
The following screenshot shows how to use this syntax in practice:

Notice that this returns an array that contains each of the original values raised to the power of 3.
For example, we can see:
- 13 = 1
- 23 = 8
- 33 = 27
- 43 =64
- 53 = 125
Note: The % symbol is an alias for the ForEach-Object cmdlet in PowerShell, which is used to perform some task on each element of an array.
Related Tutorials
The following tutorials explain how to perform other common tasks in PowerShell:
PowerShell: How to Calculate the Average of an Array
PowerShell: How to Calculate Sum of Values in Array
PowerShell: How to Find Minimum and Maximum Values in Array
PowerShell: How to Find Duplicate Values in Array
