-
Notifications
You must be signed in to change notification settings - Fork 17
/
Send-RtrGet.psm1
60 lines (52 loc) · 1.62 KB
/
Send-RtrGet.psm1
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
function Send-RtrGet {
<#
.SYNOPSIS
Batch executes 'get' command across hosts to retrieve files. After this call is made
'Confirm-RtrGetFile' is used to query for the results
.PARAMETER ID
Batch ID to execute the command on
.PARAMETER PATH
Full path to the file that is to be retrieved from each host in the batch
.PARAMETER TIMEOUT
Time to wait for the command request in seconds [default: 30, maximum 600]
.PARAMETER OPTIONAL
List of a subset of hosts we want to run the command on. If this list is supplied, only
these hosts will receive the command
#>
[CmdletBinding()]
[OutputType([psobject])]
param(
[Parameter(Mandatory = $true)]
[ValidateLength(36,36)]
[string]
$Id,
[string]
$Path,
[ValidateRange(30,600)]
[int]
$Timeout = 30,
[array]
$Optional
)
process{
$Param = @{
Uri = '/real-time-response/combined/batch-get-command/v1?timeout=' + [string] $Timeout
Method = 'post'
Header = @{
accept = 'application/json'
'content-type' = 'application/json'
}
Body = @{
batch_id = $Id
file_path = $Path
}
}
switch ($PSBoundParameters.Keys) {
'Optional' { $Param.Body['optional_hosts'] = $Optional }
'Verbose' { $Param['Verbose'] = $true }
'Debug' { $Param['Debug'] = $true }
}
$Param.Body = $Param.Body | ConvertTo-Json
Invoke-CsAPI @Param
}
}