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 ...

Get Windows PowerShell™ Scripting Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.