Please feel free to provide feedback or file bugs here.

PSBoundParameters arguments include values that were bound so far

Votes from Connect: 8

Original Date Submitted: 4/28/2015 1:48:05 AM

Description:

********Contact Information********
Handle: Adam D. Bertram
Site Name: PowerShell
Feedback ID: 1283430
***************************************

Frequency: PowerShell
Regression: I want -ShowWindow to be used for Get-Help only if I have "about_if" as the Name parameter argument.

I do this and expect a $true output if I'm using 'about_if' but it does not work.

$PSDefaultParameterValues["Get-Help:ShowWindow"] = { ($args[0].BoundParameters -contains 'Name') -and ($PSBoundParameters['Name'] -eq 'about_if') }

The reason is that $PSBoundParameters does not include param argument values for parameters that are already bound.

Problem Description:
When attempting to add a scriptblock value to $PSDefaultParameterValues hashtable I am unable to find the value of parameter arguments already bound in a cmdlet but works with a function.

$PSBoundParameters currently does not contain parameter argument values for params already bound to cmdlets.

Product Studio item created by Connect Synchronizer due to creation of feedback ID 1283430 (http://connect.microsoft.com/PowerShell/feedback/ViewFeedback.aspx?FeedbackID=1283430).

Repro Steps:
I want -ShowWindow to be used for Get-Help only if I have "about_if" as the Name parameter argument.

I do this and expect a $true output if I'm using 'about_if' but it does not work.

$PSDefaultParameterValues["Get-Help:ShowWindow"] = { ($args[0].BoundParameters -contains 'Name') -and ($PSBoundParameters['Name'] -eq 'about_if') }

The reason is that $PSBoundParameters does not include param argument values for parameters that are already bound.

Expected Results:
I should be able to get the values of bound parameters in both functions and cmdlets.

Internal BugId: 14412

1 vote
Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)

We’ll send you updates on this idea

AdminJoey Aiello [MSFT] (Program Manager, Windows Server) shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

0 comments

Sign in
(thinking…)
Sign in with: Facebook Google
Signed in as (Sign out)
Submitting...

Feedback and Knowledge Base