Powershell Tutorial Online


Windows Management Instrumentation

Type in:

PS C:\> [System.Math]::Pow(2, 3)

Look at the sytax..

What you have done is input the System.Math namespace and called the static method Pow().
Get used to the syntax; you will be using it again and again. Square brackets ‘[]’ around the fully qualified type name and two colons ‘::’ indicate I am calling the static method. Let us another example, create a variable, set it to a string and then inspect its type. You may be familiar with the GetType() method from C#.

PS C:\> $abc = "Hello"
PS C:\> $abc.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object

Set the variable $abc to a string, it is by using the GetType() method. This is becomes handy when running, tracing and debugging PowerShell scripts. You can find out exactly what type it is.