PowerShell: Check Type

By Xah Lee. Date: .

💡 TIP: 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: Object and Type

PowerShell, Boolean Related