-
Notifications
You must be signed in to change notification settings - Fork 0
/
Remove-MCDevice.ps1
56 lines (38 loc) · 1.4 KB
/
Remove-MCDevice.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
function Remove-MCDevice {
<#
.SYNOPSIS
Removes a single MobiControl device
.DESCRIPTION
Removes a single MobiControl device
.PARAMETER Token
Create the token with the script or function Get-MCToken and pass it to this function to authenticate with the MobiControl server
.PARAMETER DeviceId
Specify the device ID of the device
.NOTES
Version: 1.0
Author: Noah Li Wan Po
Creation Date: 05.06.2021
Purpose/Change: Initial function development
.EXAMPLE
.\Remove-MCDevice.ps1 Token DeviceId
.EXAMPLE
Remove-MCDevice Token DeviceId
.EXAMPLE
Add-MCDeviceGroup -Token "jdfdönbvlkö34nlk" -DeviceId "0E11AA010B4AC7B12800-0050BF7A60E2"
#>
Param (
[parameter(valuefrompipeline = $true, HelpMessage = "Enter Authentication Token", Position = 0)]
[string]$Token,
[parameter(valuefrompipeline = $true, mandatory = $true, HelpMessage = "Enter device ID", Position = 1)]
[string]$DeviceId
)
if($Token -eq ""){
$Token = Get-MCToken
}
#Header with Token Authorization
$Header = @{}
$Header["Authorization"] = "Bearer " + $Token
#API Request
$response = Invoke-restmethod -Uri https://$MCFQDN/mobicontrol/api/devices/$DeviceId -Method DELETE -Headers $Header
return $response
}