< Back

Invoke-ScriptBlock

Sat Jan 11, 2020 2:43 pm

NAME Invoke-ScriptBlock



SYNOPSIS

This function invokes a script block, catching an exception and generating an error if it occurs, and verifies the

result.





SYNTAX

Invoke-ScriptBlock [-description] <String> [-scriptBlock] <ScriptBlock> [-shouldHaveOutput] [[-expectedOutput]

<Object>] [<CommonParameters>]





DESCRIPTION

This function invokes a script block, catching an exception and generating an error if it occurs, and verifies the

result.

The result verification is only performed if an expected result is provided.





PARAMETERS

-description <String>

The description of what the script block is accomplishing.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-scriptBlock <ScriptBlock>

The script block to execute



Required? true

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-shouldHaveOutput [<SwitchParameter>]

Indicates if the script block should have output.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-expectedOutput <Object>

The expected output from the script block.



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





RELATED LINKS