-
Notifications
You must be signed in to change notification settings - Fork 17
/
Get-CsHostId.psm1
63 lines (54 loc) · 1.57 KB
/
Get-CsHostId.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
54
55
56
57
58
59
60
61
62
63
function Get-CsHostId {
<#
.SYNOPSIS
Search for hosts in your environment
.PARAMETER FILTER
The filter expression that should be used to limit the results
.PARAMETER LIMIT
The maximum records to return [default: 5000]
.PARAMETER OFFSET
The offset to page from, for the next result set
.PARAMETER HIDDEN
Switch to toggle a search of 'Hidden' devices
.PARAMETER ALL
Repeat request until all results are returned
#>
[CmdletBinding()]
[OutputType([psobject])]
param(
[string]
$Filter,
[ValidateRange(1,5000)]
[int]
$Limit = 5000,
[string]
$Offset,
[switch]
$Hidden,
[switch]
$All
)
process{
$Param = @{
Uri = '/devices/queries/devices-scroll/v1?limit=' + [string] $Limit
Method = 'get'
Header = @{
accept = 'application/json'
'content-type' = 'application/json'
}
}
switch ($PSBoundParameters.Keys) {
'Hidden' { $Param.Uri = '/devices/queries/devices-hidden/v1?limit=' + [string] $Limit }
'Filter' { $Param.Uri += '&filter=' + $Filter.ToLower() }
'Offset' { $Param.Uri += '&offset=' + $Offset }
'Debug' { $Param['Debug'] = $true }
'Verbose' { $Param['Verbose'] = $true }
}
if ($All) {
Join-CsResult -Activity $MyInvocation.MyCommand.Name -Param $Param
}
else {
Invoke-CsAPI @Param
}
}
}