Skip to content

Commit 9d9b7d7

Browse files
GitHub Action - tiPS AutomationChristelVDH
authored and
GitHub Action - tiPS Automation
committed
New tip: Capture superfluous parameters passed to your function(s)
Co-authored-by: Christel VdH <christel.vanderherten@kicts.be>
1 parent 584bd61 commit 9d9b7d7

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/PowerShellTips/2025-04-18-capture-superfluous-parameters-passed-to-your-functions.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ $tip.CreatedDate = [DateTime]::Parse('2025-04-18')
33
$tip.Title = 'Capture superfluous parameters passed to your function(s)'
44
$tip.TipText = @'
55
Capture any parsed parameter to prevent a function from bombing out when being passed unknown / misspelled variables.
6-
Comes in handy when parsing the $PSBoundparameters from a calling script with just a subset of parameters that are appropriate / needed by your (custom) function.
6+
Comes in handy when parsing the $PSBoundParameters from a calling script with just a subset of parameters that are appropriate / needed by your (custom) function.
77
'@
88
$tip.Example = @'
9-
[cmdletbinding()]
9+
[CmdletBinding()]
1010
param(
1111
[Parameter(DontShow, ValueFromRemainingArguments)]$Superfluous
1212
)
1313
1414
Write-Verbose -Message "Ignoring superfluous params: $($Superfluous -join ' ')"
1515
'@
16-
$tip.Urls = @('https://github.com/ChristelVDH/SyncAD2AAD/blob/main/ConnectTo-Graph.ps1')
16+
$tip.Urls = @('https://github.com/ChristelVDH/SyncAD2AAD/blob/main/ConnectTo-Graph.ps1','https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.parameterattribute.valuefromremainingarguments','https://learn.microsoft.com/en-us/dotnet/api/system.management.automation.parameterattribute.dontshow')
1717
$tip.Category = [tiPS.TipCategory]::Syntax # Community, Editor, Module, NativeCmdlet, Performance, Security, Syntax, Terminal, or Other.
1818
$tip.Author = 'Christel VdH' # Optional. Get credit for your tip. e.g. 'Daniel Schroeder (deadlydog)'.
1919
#$tip.ExpiryDate = [DateTime]::Parse('2024-10-30') # Optional. If the tip is not relevant after a certain date, set the expiration date. e.g. Announcing a conference or event.

0 commit comments

Comments
 (0)