-
Notifications
You must be signed in to change notification settings - Fork 0
/
Select-QueryString.ps1
49 lines (47 loc) · 1.53 KB
/
Select-QueryString.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function Select-QueryString {
[CmdletBinding(DefaultParameterSetName = "IDictionary")]
[OutputType([string])]
param(
[parameter(Mandatory = $true, ValueFromPipeline = $true, ParameterSetName = "IDictionary")]
[AllowNull()]
[AllowEmptyCollection()]
[System.Collections.IDictionary]
$InputObject,
[parameter(Mandatory = $true, ParameterSetName = "NameValueCollection")]
[AllowNull()]
[AllowEmptyCollection()]
[System.Collections.Specialized.NameValueCollection]
$NameValueCollection,
[parameter(Position = 1, Mandatory = $true)]
[Alias("Name")]
[AllowNull()]
[AllowEmptyCollection()]
[AllowEmptyString()]
[string[]]
$Key
)
process {
if ($InputObject -ne $null) {
foreach ($i in (ToString $Key)) {
$list = $InputObject[$i]
if (IsEmpty $list) {
$PSCmdlet.WriteObject([string]::Empty, $false)
}
else {
ToString $list
}
}
}
if ($NameValueCollection -ne $null) {
foreach ($i in (ToString $Key)) {
$list = $NameValueCollection.GetValues($i)
if (IsEmpty $list) {
$PSCmdlet.WriteObject([string]::Empty, $false)
}
else {
ToString $list
}
}
}
}
}