Home Dashboard Directory Help
Search

$PSBoundParameters + $PSDefaultParameterValues[Cmdlet] = bug by S.K. _


Status: 

Active


3
0
Sign in
to vote
Type: Bug
ID: 775020
Opened: 12/22/2012 8:04:59 AM
Access Restriction: Public
0
Workaround(s)
view
0
User(s) can reproduce this bug

Description

# CASE1: function
PS > function aaa ( [Parameter(ValueFromPipeline)]$aaa, $bbb, $ccc , $ddd ) { }
PS > $PSDefaultParameterValues['aaa:ddd'] = { $PSBoundParameters >> aaa.log }
PS > 1..5 | aaa -bbb BBB -ccc CCC
PS > cat .\aaa.log

Key                                 Value
---                                 -----
bbb                                 BBB
ccc                                 CCC
aaa                                 1

... 2,3,4 ...

Key                                 Value
---                                 -----
bbb                                 BBB
ccc                                 CCC
aaa                                 5


Parameters are reflected in $PSBoundParameters.



# CASE2: Cmdlet
PS > $PSDefaultParameterValues['Get-ChildItem:Force'] = { $PSBoundParameters >> bbb.log }

PS > $PSDefaultParameterValues['Get-ChildItem:Force'] = {
     "`n---`$args[0].BoundParameters---" >> bbb.log
     $args[0].BoundParameters >> bbb.log
     "`n+++`$PSBoundParameters+++" >> bbb.log
     $PSBoundParameters >> bbb.log
     }

PS > ls -path .\aaa.log -File -Verbose
PS > cat bbb.log

---$args[0].BoundParameters---
Path
Verbose

+++$PSBoundParameters+++

---$args[0].BoundParameters---
Path
Verbose
File

+++$PSBoundParameters+++

---$args[0].BoundParameters---
Path
Verbose
File

+++$PSBoundParameters+++


Parameters are not reflected in $PSBoundParameters.
Details
Sign in to post a comment.
Posted by MrSytone on 10/7/2013 at 9:04 AM
Confirmed in Version 4.0 as well.


Name             : ConsoleHost
Version         : 4.0
InstanceId     : 8ec4bcc2-2003-43d2-848f-d309ceac59fb
UI             : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture : en-US
CurrentUICulture : en-US
PrivateData     : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace
Sign in to post a workaround.