Search

Add support for splatting collections that are stored as a property of an object by Kirk Munro

Active

2
0
Sign in
to vote
Type: Suggestion
ID: 778964
Opened: 2/11/2013 7:21:04 AM
Access Restriction: Public
0
Workaround(s)
PowerShell should allow users to splat collections that are stored in a property of an object. For example, you can splat PSBoundParameters like this:

Test-Something @PSBoundParameters

You should also be able to splat PSBoundParameters like this:

Test-Something @PSCmdlet.MyInvocation.BoundParameters

This leverages the @ symbol to indicate something is being splatted, but adds support for dereferencing objects in the process.

This feature would make for much simpler splatting logic, especially if implemented at the same time as this request:

https://connect.microsoft.com/PowerShell/feedback/details/778931/fault-tolerant-splatting#details
Details (expand)
How often does this happen?
Always Happens
Have you seen this problem before in this product?
Yes, this happens in all previous versions
Reproduction Steps
$splat = New-Object PSObject -Property @{
    Scenario1 = @{
        LiteralPath = C:\Windows
    }
    Scenario2 = @{
        Path = C:\W*
    }
}
Get-ChildItem @splat.Scenario1
Expected Results
The contents of C:\Windows should be returned from the call to Get-ChildItem
File Attachments
0 attachments
Sign in to post a comment.
Sign in to post a workaround.