< Back

Invoke-PodeScriptBlock

Sat Jan 18, 2020 7:16 pm

NAME Invoke-PodeScriptBlock



SYNOPSIS

Invokes a ScriptBlock.





SYNTAX

Invoke-PodeScriptBlock [-ScriptBlock] <ScriptBlock> [[-Arguments] <Object>] [-Scoped] [-Return] [-Splat]

[-NoNewClosure] [<CommonParameters>]





DESCRIPTION

Invokes a ScriptBlock, supplying optional arguments, splatting, and returning any optional values.





PARAMETERS

-ScriptBlock <ScriptBlock>

The ScriptBlock to invoke.



Required? true

Position? 1

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Arguments <Object>

Any arguments that should be supplied to the ScriptBlock.



Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Scoped [<SwitchParameter>]

Run the ScriptBlock in a scoped context.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Return [<SwitchParameter>]

Return any values that the ScriptBlock may return.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-Splat [<SwitchParameter>]

Spat the argument onto the ScriptBlock.



Required? false

Position? named

Default value False

Accept pipeline input? false

Accept wildcard characters? false



-NoNewClosure [<SwitchParameter>]

Don't create a new closure before invoking the ScriptBlock.



Required? false

Position? named

Default value False

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

System.Object





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



PS C:\\>Invoke-PodeScriptBlock -ScriptBlock { Write-Host 'Hello!' }













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



PS C:\\>Invoke-PodeScriptBlock -Arguments 'Morty' -ScriptBlock { /* logic */ }















RELATED LINKS