O'Reilly logo

Windows PowerShell™ Scripting Guide by Ed Wilson

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

Working with Data Types

Windows PowerShell is a strongly typed language that acts as if it were typeless. This is because Windows PowerShell does a good job of detecting data types and acting on them accordingly. If something appears to be a string, Windows PowerShell will treat it as a string. As an example, consider these three statements:

PS C:\> 1 + 1
2
PS C:\> 12:00 + :30
Unexpected token ':00' in expression or statement.
At line:1 char:6
+ 12:00  <<<< + :30
PS C:\> a + b
The term 'a' is not recognized as a cmdlet, function, operable program,
or script file. Verify the term and try again At line:1 char:2 + a  <<<< + b
PS C:\>

Notice that only one statement completed without error—the one containing 1 + 1. Windows PowerShell properly detected ...

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