Josh Petitt
Josh Petitt

Reputation: 9579

PowerShell how to unsplat

I know how to use splatting to pass parameters to a cmdlet.

How would I write a cmdlet to "unsplat"? I want to get all the parameters passed to my function as a hashtable.

For example:

function Test-Unsplat
{
    [cmdletbinding()]

    param(
        $ParamA,
        $ParamB
    )

    # WHAT TO DO HERE TO GET @{ParamA = '...', ParamB = '...'}
}

Upvotes: 2

Views: 202

Answers (1)

Josh Petitt
Josh Petitt

Reputation: 9579

I found the answer with

Get-Help about_Splatting

The answer I was looking for is $PSBoundParameters.

Upvotes: 1

Related Questions