-
Notifications
You must be signed in to change notification settings - Fork 206
/
Copy pathSet-MGDDevice.ps1
120 lines (102 loc) · 3.89 KB
/
Set-MGDDevice.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#Requires -Version 5.0
#requires -Modules Microsoft.Graph.Identity.DirectoryManagement
<#
.SYNOPSIS
Updates the device
.DESCRIPTION
.NOTES
This PowerShell script was developed and optimized for ScriptRunner. The use of the scripts requires ScriptRunner.
The customer or user is authorized to copy the script from the repository and use them in ScriptRunner.
The terms of use for ScriptRunner do not apply to this script. In particular, ScriptRunner Software GmbH assumes no liability for the function,
the use and the consequences of the use of this freely available script.
PowerShell is a product of Microsoft Corporation. ScriptRunner is a product of ScriptRunner Software GmbH.
© ScriptRunner Software GmbH
.COMPONENT
Requires Library script MS Graph\_LIB_\MGLibrary
Requires Modules Microsoft.Graph.Identity.DirectoryManagement
.LINK
https://github.com/scriptrunner/ActionPacks/tree/master/MS%20Graph/Device
.Parameter DeviceId
[sr-en] Identifier of the device
[sr-de] Geräte-ID
.Parameter AccountEnabled
[sr-en] The account is enabled
[sr-de] Geräte-Konto ist aktiv
.Parameter IsCompliant
[sr-en] Device complies with Mobile Device Management (MDM) policies
[sr-de] Gerät entspricht den Richtlinien für Mobile Device Management (MDM)
.Parameter IsManaged
[sr-en] Device is managed by a Mobile Device Management (MDM) app
[sr-de] Gerät wird von einer Mobile Device Management (MDM)-App verwaltet
.Parameter DisplayName
[sr-en] Display name for the device
[sr-de] Anzeigenamen des Geräts
.Parameter DeviceVersion
[sr-en] Version of the device
[sr-de] Version des Geräts
.Parameter OperatingSystem
[sr-en] Operating system
[sr-de] Betriebssystem
.Parameter OperatingSystemVersion
[sr-en] Version of the operating system
[sr-de] Betriebssystemversion
.Parameter ProfileType
[sr-en] Profile type of the device
[sr-de] Profil-Typ des Geräts
#>
param(
[Parameter(Mandatory= $true)]
[string]$DeviceId,
[switch]$AccountEnabled,
[bool]$IsCompliant,
[bool]$IsManaged,
[string]$DisplayName,
[string]$DeviceVersion,
[string]$OperatingSystem,
[string]$OperatingSystemVersion,
[ValidateSet('RegisteredDevice','SecureVM','Printer','Shared','IoT')]
[string]$ProfileType = 'RegisteredDevice'
)
Import-Module Microsoft.Graph.Identity.DirectoryManagement
try{
[hashtable]$cmdArgs = @{ErrorAction = 'Stop'
'PassThru' = $null
'Confirm' = $false
'DeviceId' = $DeviceId
'ProfileType' = $ProfileType
}
if($AccountEnabled.IsPresent){
$cmdArgs.Add('AccountEnabled',$null)
}
if($PSBoundParameters.ContainsKey('IsCompliant') -eq $true){
$cmdArgs.Add('IsCompliant',$IsCompliant)
}
if($PSBoundParameters.ContainsKey('IsManaged') -eq $true){
$cmdArgs.Add('IsManaged',$IsManaged)
}
if($PSBoundParameters.ContainsKey('DisplayName') -eq $true){
$cmdArgs.Add('DisplayName',$DisplayName)
}
if($PSBoundParameters.ContainsKey('DeviceVersion') -eq $true){
$cmdArgs.Add('DeviceVersion',$DeviceVersion)
}
if($PSBoundParameters.ContainsKey('OperatingSystem') -eq $true){
$cmdArgs.Add('OperatingSystem',$OperatingSystem)
}
if($PSBoundParameters.ContainsKey('OperatingSystemVersion') -eq $true){
$cmdArgs.Add('OperatingSystemVersion',$OperatingSystemVersion)
}
$null = Update-MgDevice @cmdArgs
$result = Get-MgDevice -DeviceId $DeviceId -ErrorAction Stop | Select-Object *
if($SRXEnv) {
$SRXEnv.ResultMessage = $result
}
else{
Write-Output $result
}
}
catch{
throw
}
finally{
}