-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get-MCDeviceGroups.ps1
63 lines (44 loc) · 1.9 KB
/
Get-MCDeviceGroups.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
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-MCDeviceGroups {
<#
.SYNOPSIS
Gets all MobiControl device groups or selected subgroups from parent folder
.DESCRIPTION
Gets all MobiControl the device groups if no path is specified. If a path of a parent groups is specified it gets the child groups.
.PARAMETER Token
Create the token with the script or function Get-MCToken and pass it to this function to authenticate with the MobiControl server. Leave it blank and the function will be called to enter the details.
.PARAMETER parentPath
Specify the parent group to show the subgroups
If not specified all device groups will be listed recursively
.OUTPUTS
all Device group or sub groups of the specified parent
.NOTES
Version: 1.0
Author: Noah Li Wan Po
Creation Date: 10.06.2020
Purpose/Change: Initial function development
.EXAMPLE
.\Get-MCDeviceGroups.ps1 Token Path
.EXAMPLE
Get-MCDeviceGroups Token Path
.EXAMPLE
Get-MCDeviceGroup -Token jdfdönbvlkö34nlk -Path \\root\subgroup
#>
Param (
[parameter(valuefrompipeline = $true, HelpMessage = "Enter Authentication Token", Position = 0)]
[string]$Token,
[parameter(valuefrompipeline = $true, HelpMessage = "Enter parentPath", Position = 1)]
[string]$parentPath
)
if($Token -eq ""){
$Token = Get-MCToken
}
$Header = @{}
$Header["Authorization"] = "Bearer " + $Token
if($parentPath -ne $null){
$response = Invoke-restmethod -Uri https://$MCFQDN/mobicontrol/api/devicegroups?parentPath=$parentpath -ContentType "application/json" -Method GET -Headers $Header
}
else{
$response = Invoke-restmethod -Uri https://$MCFQDN/mobicontrol/api/devicegroups -ContentType "application/json" -Method GET -Headers $Header
}
return $response
}