forked from Cephalowat/PSFalcon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStart-RtrBatch.psm1
53 lines (47 loc) · 1.46 KB
/
Start-RtrBatch.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
function Start-RtrBatch {
<#
.SYNOPSIS
Batch initialize a RTR session on multiple hosts. Before any RTR commands
can be used, an active session is needed on the host
.PARAMETER ID
List of host agent IDs to initialize a RTR session on
.PARAMETER EXISTING
Optional batch ID. Use an existing batch ID if you want to initialize new hosts and
add them to an existing batch
.PARAMETER TIMEOUT
Time to wait for the command request to complete, in seconds [default: 30]
#>
[CmdletBinding()]
[OutputType([psobject])]
param(
[Parameter(Mandatory = $true)]
[array]
$Id,
[ValidateLength(36,36)]
[string]
$Existing,
[ValidateRange(30,600)]
[int]
$Timeout = 30
)
process{
$Param = @{
Uri = '/real-time-response/combined/batch-init-session/v1?timeout=' + [string] $Timeout
Method = 'post'
Header = @{
accept = 'application/json'
'content-type' = 'application/json'
}
Body = @{
host_ids = $Id
}
}
switch ($PSBoundParameters.Keys) {
'Existing' { $Param.Body['existing_batch_id'] = $Existing }
'Verbose' { $Param['Verbose'] = $true }
'Debug' { $Param['Debug'] = $true }
}
$Param.Body = $Param.Body | ConvertTo-Json
Invoke-CsAPI @Param
}
}