-
-
Notifications
You must be signed in to change notification settings - Fork 91
/
Copy pathGet-PASRequest.ps1
110 lines (77 loc) · 1.95 KB
/
Get-PASRequest.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# .ExternalHelp psPAS-help.xml
function Get-PASRequest {
[CmdletBinding()]
param(
[parameter(
Mandatory = $true,
ValueFromPipelinebyPropertyName = $true,
ParameterSetName = 'Requests'
)]
[ValidateNotNullOrEmpty()]
[ValidateSet('MyRequests', 'IncomingRequests')]
[string]$RequestType,
[parameter(
Mandatory = $true,
ValueFromPipelinebyPropertyName = $true,
ParameterSetName = 'bulkactions'
)]
[int]$id,
[parameter(
Mandatory = $true,
ValueFromPipelinebyPropertyName = $true,
ParameterSetName = 'Requests'
)]
[boolean]$OnlyWaiting,
[parameter(
Mandatory = $true,
ValueFromPipelinebyPropertyName = $true,
ParameterSetName = 'Requests'
)]
[boolean]$Expired,
[parameter(
Mandatory = $false,
ValueFromPipelinebyPropertyName = $true,
ParameterSetName = 'bulkactions'
)]
[boolean]$DisplayExtendedItems
)
BEGIN {
Assert-VersionRequirement -RequiredVersion 9.10
}#begin
PROCESS {
#Create URL for Request
switch ($PSCmdlet.ParameterSetName) {
'bulkactions' {
Assert-VersionRequirement -RequiredVersion 13.2
$URI = "$($psPASSession.BaseURI)/API/$($PSCmdlet.ParameterSetName)/$id"
break
}
'Requests' {
$URI = "$($psPASSession.BaseURI)/API/$($RequestType)"
break
}
}
#Create QueryString
$queryString = $PSBoundParameters | Get-PASParameter -ParametersToRemove RequestType, id | ConvertTo-QueryString
if ($null -ne $queryString) {
#Add QueryString to URL
$URI = "$URI`?$queryString"
}
#send request to PAS web service
$result = Invoke-PASRestMethod -Uri $URI -Method GET
If ($null -ne $result) {
#Return Results
switch ($PSCmdlet.ParameterSetName) {
'bulkactions' {
$result | Add-ObjectDetail -typename psPAS.CyberArk.Vault.Request.BulkAction
break
}
'Requests' {
$result.$RequestType | Add-ObjectDetail -typename psPAS.CyberArk.Vault.Request.Details
break
}
}
}
}#process
END { }#end
}