forked from Cephalowat/PSFalcon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAdd-CsGroupMember.psm1
49 lines (45 loc) · 1.27 KB
/
Add-CsGroupMember.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
function Add-CsGroupMember {
<#
.SYNOPSIS
Add Hosts to a static Host Group
.PARAMETER ID
The Host Group ID
.PARAMETER HOSTS
One or more Agent IDs to add to the Host Group
#>
[CmdletBinding()]
[OutputType([psobject])]
param(
[Parameter(Mandatory = $true)]
[ValidateLength(32,32)]
[string]
$Id,
[Parameter(Mandatory = $true)]
[array]
$Hosts
)
process{
[string] $HostString = foreach ($Item in $Hosts) { "`'" + $Item + "`'," }
$Param = @{
Uri = '/devices/entities/host-group-actions/v1?action_name=add-hosts'
Method = 'post'
Header = @{
accept = 'application/json'
'content-type' = 'application/json'
}
Body = @{
action_parameters = @(
@{ name = 'filter'
value = '(device_id:[' + ($HostString).TrimEnd(',') + '])'
}
)
ids = @( $Id )
} | Convertto-Json
}
switch ($PSBoundParameters.Keys) {
'Verbose' { $Param['Verbose'] = $true }
'Debug' { $Param['Debug'] = $true }
}
Invoke-CsAPI @Param
}
}