Assert-Is

Asserts that an object is a specific type.

Syntax

Assert-Is [[-InputObject] <Object>] [[-ExpectedType] <Type>] [[-Message] <String>] [<CommonParameters>]

Description

Uses PowerShell's -is operator to check that InputObject is the ExpectedType type.

Parameters

Name Type Description Required? Pipeline Input Default Value
InputObject Object

The object whose type to check.

false false
ExpectedType Type

The expected type of the object.

false false
Message String

A message to show when the assertion fails.

false false

EXAMPLE 1

Assert-Is 'foobar' ([string])

Demonstrates how to assert an object is of a specific type.

EXAMPLE 2

Assert-Is 1 'double' 'Not enough decimals!'

Demonstrates how to show a message describing why the test might fail.