Skip to content

Commit 57a0d24

Browse files
author
Friedrich Weinmann
committed
Reintroduced conflicting help uri
1 parent c12e7ab commit 57a0d24

2 files changed

Lines changed: 82 additions & 1 deletion

File tree

PSFramework/functions/runspace/Set-PSFDynamicContentObject.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
#>
6262
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSUseShouldProcessForStateChangingFunctions", "")]
6363
[OutputType([PSFramework.Utility.DynamicContentObject])]
64-
[CmdletBinding()]
64+
[CmdletBinding(HelpUri = 'https://psframework.org/documentation/commands/PSFramework/Set-PSFDynamicContentObject')]
6565
Param (
6666
[string[]]
6767
$Name,
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
function Test-PSFParameterBinding
2+
{
3+
<#
4+
.SYNOPSIS
5+
Helper function that tests, whether a parameter was bound.
6+
7+
.DESCRIPTION
8+
Helper function that tests, whether a parameter was bound.
9+
10+
.PARAMETER ParameterName
11+
The name(s) of the parameter that is tested for being bound.
12+
By default, the check is true when AT LEAST one was bound.
13+
14+
.PARAMETER Not
15+
Reverses the result. Returns true if NOT bound and false if bound.
16+
17+
.PARAMETER And
18+
All specified parameters must be present, rather than at least one of them.
19+
20+
.PARAMETER BoundParameters
21+
The hashtable of bound parameters. Is automatically inherited from the calling function via default value. Needs not be bound explicitly.
22+
23+
.EXAMPLE
24+
if (Test-PSFParameterBinding "Day")
25+
{
26+
27+
}
28+
29+
Snippet as part of a function. Will check whether the parameter "Day" was bound. If yes, whatever logic is in the conditional will be executed.
30+
31+
.EXAMPLE
32+
Test-PSFParameterBinding -Not 'Login', 'Spid', 'ExcludeSpid', 'Host', 'Program', 'Database'
33+
34+
Returns whether none of the parameters above were specified.
35+
36+
.EXAMPLE
37+
Test-PSFParameterBinding -And 'Login', 'Spid', 'ExcludeSpid', 'Host', 'Program', 'Database'
38+
39+
Returns whether any of the specified parameters was not bound
40+
#>
41+
[CmdletBinding(HelpUri = 'https://psframework.org/documentation/commands/PSFramework/Test-PSFParameterBinding')]
42+
Param (
43+
[Parameter(Mandatory = $true, Position = 0)]
44+
[string[]]
45+
$ParameterName,
46+
47+
[Alias('Reverse')]
48+
[switch]
49+
$Not,
50+
51+
[switch]
52+
$And,
53+
54+
[object]
55+
$BoundParameters = (Get-PSCallStack)[0].InvocationInfo.BoundParameters
56+
)
57+
58+
if ($And)
59+
{
60+
$test = $true
61+
}
62+
else
63+
{
64+
$test = $false
65+
}
66+
67+
foreach ($name in $ParameterName)
68+
{
69+
if ($And)
70+
{
71+
if (-not $BoundParameters.ContainsKey($name)) { $test = $false }
72+
}
73+
else
74+
{
75+
if ($BoundParameters.ContainsKey($name)) { $test = $true }
76+
}
77+
}
78+
79+
return ((-not $Not) -eq $test)
80+
}
81+
if (-not (Test-Path Alias:Was-Bound)) { Set-Alias -Value Test-PSFParameterBinding -Name Was-Bound -Scope Global }

0 commit comments

Comments
 (0)