< Back

Assert-Is

Sun Jan 12, 2020 5:42 pm

NAME Assert-Is



SYNOPSIS

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

-InputObject <Object>

The object whose type to check.



Required? false

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ExpectedType <Type>

The expected type of the object.



Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Message <String>

A message to show when the assertion fails.



Required? false

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Assert-Is 'foobar' ([string])



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









-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Assert-Is 1 'double' 'Not enough decimals!'



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











RELATED LINKS