@@ -6377,7 +6377,7 @@ $([Security.SecurityElement]::Escape($VisibilityCondition[$c]))
63776377
63786378 # If provided, will colorize all rows in a table, according to the script block.
63796379 # If the script block returns a value, it will be treated either as an ANSI escape sequence or up to two hexadecimal colors
6380- [Parameter(ValueFromPipelineByPropertyName=$true )]
6380+ [Parameter(ValueFromPipelineByPropertyName)]
63816381 [Alias('ColourRow')]
63826382 [ScriptBlock]$ColorRow,
63836383
@@ -6409,20 +6409,21 @@ $([Security.SecurityElement]::Escape($VisibilityCondition[$c]))
64096409
64106410 # If provided, the table view will only be used if the the typename includes this value.
64116411 # This is distinct from the overall typename, and can be used to have different table views for different inherited objects.
6412- [Parameter(ValueFromPipelineByPropertyName=$true )]
6412+ [Parameter(ValueFromPipelineByPropertyName)]
64136413 [string]
64146414 $ViewTypeName,
64156415
64166416 # If provided, the table view will only be used if the the typename is in a SelectionSet.
64176417 # This is distinct from the overall typename, and can be used to have different table views for different inherited objects.
6418- [Parameter(ValueFromPipelineByPropertyName=$true )]
6418+ [Parameter(ValueFromPipelineByPropertyName)]
64196419 [string]
64206420 $ViewSelectionSet,
64216421
64226422 # If provided, will selectively display items.
6423- [Parameter(ValueFromPipelineByPropertyName=$true )]
6423+ [Parameter(ValueFromPipelineByPropertyName)]
64246424 [ScriptBlock]
6425- $ViewCondition)
6425+ $ViewCondition
6426+ )
64266427
64276428 begin {
64286429 $rowEntries = @()
@@ -6431,9 +6432,25 @@ $([Security.SecurityElement]::Escape($VisibilityCondition[$c]))
64316432 if ($_ -is [scriptblock]) { "`$(`$Script:_LastCellStyle = `$(`$__ = `$_;. {$($_)};`$_ = `$__);`$Script:_LastCellStyle)"}
64326433 else { "`$(`$Script:_LastCellStyle ='$($_)';`$Script:_LastCellStyle)" }
64336434 }
6435+
6436+ $myParameterNames = @(($MyInvocation.MyCommand -as [Management.Automation.CommandMetadata]).Keys) -as [string[]]
64346437 }
64356438
64366439 process {
6440+ # ValueFromPipelineByPropertyName is great, but it is "sticky".
6441+ # Parameters that have been bound aren't "unbound" until a new value is provided.
6442+ # This means that if a parameter is not provided, it will keep the last value.
6443+ # And that's what we call an unexpected side effect.
6444+ # In order to avoid this, we walk over our list of parameter names
6445+ foreach ($parameterName in $myParameterNames) {
6446+ # if they are not in the bound parameters
6447+ if (-not $PSBoundParameters.ContainsKey($parameterName)) {
6448+ # we nullify them
6449+ try { $ExecutionContext.SessionState.PSVariable.Set($parameterName, $null) }
6450+ # and if we can't, we write a verbose message.
6451+ catch { Write-Verbose "Could not nullify '$parameterName': $_ " }
6452+ }
6453+ }
64376454 $tableHeader = ''
64386455 $rowColumns =
64396456 @(for ($i =0; $i -lt $property.Count; $i++) {
0 commit comments