PowerShell: Check Type

By Xah Lee. Date: .

Operator names are case-insensitive.

value -is type
test if a value is a given type.

WARNING: the value to be tested must be on the left-hand-side.

# all True

3 -is [int]

3.4 -is [double]

"abc" -is [string]

3,4 -is [Array]
# all True

3 -is (3).GetType()

$x = "abc"
$x -is $x.GetType()
value -isnot type
negation of -is

PowerShell: Value Types

PowerShell Operators

PowerShell

Practical How-To

list files

list dirs

on dir

on file

Windows config

zip tar

misc


PowerShell in Depth

Programing PowerShell

Value Types

String

Variable

Boolean

Conditional

Data Structure

Loop and Iteration

Input/Output

Function

Profile and Script

Script Examples