-
Notifications
You must be signed in to change notification settings - Fork 17
/
Hide-CsHost.psm1
50 lines (48 loc) · 1.44 KB
/
Hide-CsHost.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
function Hide-CsHost {
<#
.SYNOPSIS
Delete hosts. After a host is deleted, no new detections for that host
will be reported in the UI or APIs
.PARAMETER ID
An array of one or more agent IDs to hide
#>
[CmdletBinding()]
[OutputType([psobject])]
param(
[Parameter(Mandatory = $true)]
[array]
$Id
)
begin{
# Maximum number of hosts per request
$Max = 100
}
process{
# Base parameters
$Param = @{
Uri = '/devices/entities/devices-actions/v2?action_name=hide_host'
Method = 'post'
Header = @{
accept = 'application/json'
'content-type' = 'application/json'
}
}
switch ($PSBoundParameters.Keys) {
'Verbose' { $Param['Verbose'] = $true }
'Debug' { $Param['Debug'] = $true }
}
# Make request for each group of $Max
for ($i = 0; $i -lt $Id.count; $i += $Max) {
if ($i -gt 0) {
$Progress = @{
Activity = $MyInvocation.MyCommand.Name
Status = [string] $i + ' of ' + [string] $Id.count
PercentComplete = (($i/$Id.count)*100)
}
Write-Progress @Progress
}
$Param['Body'] = @{ 'ids' = @($Id[$i..($i + ($Max - 1))]) } | ConvertTo-Json
Invoke-CsAPI @Param
}
}
}