O'Reilly logo

Mastering Windows PowerShell Scripting by Brenton J.W. Blawat

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Number manipulation and parsing

PowerShell is a powerful mathematics calculator. In fact, PowerShell has an entire Windows class dedicated to mathematics calculations that can be called by using the [System.Math] .NET class. When you are working with the [System.Math] classes, it is common to call static fields within a class. Static fields are static properties, methods, and objects that can be called to display data or do actions. To call a static field, you call the [Math] (shortened version of [System.Math]) class, followed by two colons :: and the static field name.

To use the math operation to calculate pi, execute the following command:

[math]::pi

The output of this is shown in the following screenshot:

This simple command will provide PI ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required