-
Notifications
You must be signed in to change notification settings - Fork 17
/
Confirm-RtrBatch.psm1
51 lines (45 loc) · 1.4 KB
/
Confirm-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
function Confirm-RtrBatch {
<#
.SYNOPSIS
Batch refresh a RTR session on multiple hosts. RTR sessions will expire
after 10 minutes unless refreshed
.PARAMETER ID
Batch ID to execute the command on
.PARAMETER TIMEOUT
Timeout for how long to wait for the request in seconds [default: 30, maximum 600]
.PARAMETER REMOVE
An array of agent IDs to remove from the batch session. Heartbeats will no longer happen on these
hosts and the sessions will expire
#>
[CmdletBinding()]
[OutputType([psobject])]
param(
[Parameter(Mandatory = $true)]
[ValidateLength(36,36)]
[string]
$Id,
[ValidateRange(30,600)]
[int]
$Timeout = 30,
[array]
$Remove
)
process{
$Param = @{
Uri = '/real-time-response/combined/batch-refresh-session/v1?timeout=' + [string] $Timeout
Method = 'post'
Header = @{
accept = 'application/json'
'content-type' = 'application/json'
}
Body = @{ batch_id = $Id }
}
switch ($PSBoundParameters.Keys) {
'Remove' { $Param.Body['hosts_to_remove'] }
'Verbose' { $Param['Verbose'] = $true }
'Debug' { $Param['Debug'] = $true }
}
$Param.Body = $Param.Body | ConvertTo-Json
Invoke-CsAPI @Param
}
}