Skip to content

Commit 584bd61

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 7de8557 commit 584bd61

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
$tip = [tiPS.PowerShellTip]::new()
2+
$tip.CreatedDate = [DateTime]::Parse('2025-04-18')
3+
$tip.Title = 'Capture superfluous parameters passed to your function(s)'
4+
$tip.TipText = @'
5+
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.
7+
'@
8+
$tip.Example = @'
9+
[cmdletbinding()]
10+
param(
11+
[Parameter(DontShow, ValueFromRemainingArguments)]$Superfluous
12+
)
13+
14+
Write-Verbose -Message "Ignoring superfluous params: $($Superfluous -join ' ')"
15+
'@
16+
$tip.Urls = @('https://github.com/ChristelVDH/SyncAD2AAD/blob/main/ConnectTo-Graph.ps1')
17+
$tip.Category = [tiPS.TipCategory]::Syntax # Community, Editor, Module, NativeCmdlet, Performance, Security, Syntax, Terminal, or Other.
18+
$tip.Author = 'Christel VdH' # Optional. Get credit for your tip. e.g. 'Daniel Schroeder (deadlydog)'.
19+
#$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.
20+
21+
# Tip submitted via GitHub issue workflow.

0 commit comments

Comments
 (0)