Skip to content

Convert-PodeScopedVariables,what it is for #1632

@ericxin1982

Description

@ericxin1982

Conversion
If you have a ScriptBlock that you need to convert, in an ad-hoc manner, you can manually call Convert-PodeScopedVariables yourself. You should supply the -ScriptBlock to wish to convert, as well as an optional -PSSession SessionState from $PSCmdlet.SessionState, to this function:

convert the scriptblock's scoped variables

$ScriptBlock, $usingVars = Convert-PodeScopedVariables -ScriptBlock $ScriptBlock -PSSession $PSCmdlet.SessionState

invoke the converted scriptblock, and supply any using variable values

$result = Invoke-PodeScriptBlock -ScriptBlock $ScriptBlock -UsingVariables $usingVars -Splat -Return

Hi @Badgerati

I read document about scoped variables, and this conversion I get lost, how to use this, even if right now I do not need it yet but better understand still would be good.

Thanks
Eric Xin

Metadata

Metadata

Assignees

No one assigned

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions