-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCB-DefenseAPI.ps1
29 lines (24 loc) · 1.17 KB
/
CB-DefenseAPI.ps1
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
#Defaults
$Script:Token = $null
$ApiHost = 'https://yourinstance.conferdeploy.net/integrationServices/v3'
function Invoke-CbApi{
param(
[string]$Command,
[ValidateSet('Get','Delete','Post','Put','Patch')]
[string]$Method='Get',
[string]$JsonBody
)
If($Script:Token -eq $null){
$Script:Token = 'apikey/connectorstring'
}
If($JsonBody -and $Method){
return Invoke-WebRequest -UseBasicParsing -Uri "$ApiHost/$Command" -Headers @{'X-Auth-Token'=$Token;'Content-Type'='application/json'} -Method $Method -Body $JsonBody -ContentType application/json
}Else{
return Invoke-WebRequest -UseBasicParsing -Uri "$ApiHost/$Command" -Headers @{'X-Auth-Token'=$Token} -Method $Method -ContentType application/json
}
}
$System = Read-Host -Prompt 'Enter host name'
Write-Host "`n===============CB DEFENSE===============`n" -ForegroundColor Yellow
$DefResponse = (Invoke-CbApi -Command "device?hostName=$System").Content | ConvertFrom-Json | Select -ExpandProperty results
$DefResponse = [PSCustomObject]$DefResponse
$DefResponse | select * | ft -Property name,status,sensorVersion,osVersion,lastContact