Repository navigation
Expand file tree
/
Copy pathTemplate.ps1
More file actions
273 lines (235 loc) · 8.49 KB
/
Copy pathTemplate.ps1
File metadata and controls
273 lines (235 loc) · 8.49 KB
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# Write the comment-based HELP for New-IntuneConfigurationProfile
function New-IntuneConfigurationProfile
{
param(
[string]$Name,
[string]$Description,
[ValidateSet(
"windows10",
"iOS"
)]
[string]$Platform,
[string]$Technologies="mdm",
[psobject[]]$Settings,
[string[]]$RoleScopeTagIds=@("0"),
[ValidateSet("Global", "USGov", "USGovDoD")]
[string]$Environment="Global"
)
begin
{
if($false -eq (Initialize-IntuneAccess -Scopes @("DeviceManagementConfiguration.ReadWrite.All") -Modules @("Microsoft.Graph.Authentication") -Environment $Environment))
{
return
}
switch ($Environment) {
"USGov" { $uri = "https://graph.microsoft.us" }
"USGovDoD" { $uri = "https://dod-graph.microsoft.us" }
Default { $uri = "https://graph.microsoft.com" }
}
$graphVersion = "beta"
}
process
{
$body = @{}
if($Name)
{
$body.name = $Name
}
if($Description)
{
$body.description = $Description
}
if($Platform)
{
$body.platforms = $Platform
}
if($Technologies)
{
$body.technologies = $Technologies
}
if($Settings)
{
$body.settings = $Settings
}
if($RoleScopeTagIds)
{
$body.roleScopeTagIds = $RoleScopeTagIds
}
$response = Invoke-MgRestMethod -Method Post -Uri "$uri/$graphVersion/deviceManagement/configurationPolicies" -Body ($body | ConvertTo-Json -Depth 50) -ContentType "application/json" -OutputType Json | ConvertFrom-Json
return $response
}
}
# Write the comment-based HELP for Remove-IntuneConfigurationProfile
<#
.SYNOPSIS
Removes an Intune configuration profile.
.DESCRIPTION
Removes an Intune configuration profile.
.PARAMETER Id
The id of the configuration profile to remove.
.PARAMETER Environment
The environment to connect to. Valid values are Global, USGov, USGovDoD. Default is Global.
.EXAMPLE
# Remove a configuration profile.
Remove-IntuneConfigurationProfile -Id "00000000-0000-0000-0000-000000000000"
.EXAMPLE
# Remove a configuration profile in the USGov environment.
Remove-IntuneConfigurationProfile -Id "00000000-0000-0000-0000-000000000000" -Environment USGov
#>
function Remove-IntuneConfigurationProfile
{
param (
[Parameter(Mandatory, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName="id")]
[string]$Id,
[ValidateSet("Global", "USGov", "USGovDoD")]
[string]$Environment="Global"
)
begin {
if($false -eq (Initialize-IntuneAccess -Scopes @("DeviceManagementConfiguration.ReadWrite.All") -Modules @("Microsoft.Graph.Authentication") -Environment $Environment))
{
return
}
switch ($Environment) {
"USGov" { $uri = "https://graph.microsoft.us" }
"USGovDoD" { $uri = "https://dod-graph.microsoft.us" }
Default { $uri = "https://graph.microsoft.com" }
}
$graphVersion = "beta"
}
process {
Invoke-MgRestMethod -Method Delete -Uri "$uri/$graphVersion/deviceManagement/configurationPolicies/$Id" -OutputType Json | ConvertFrom-Json
}
}
# Write the comment-based HELP for Update-IntuneConfigurationProfile
<#
.SYNOPSIS
Updates an Intune configuration profile.
.DESCRIPTION
Updates an Intune configuration profile.
.PARAMETER Id
The id of the configuration profile to update.
.PARAMETER Name
The name of the configuration profile to update.
.PARAMETER Description
The description of the configuration profile to update.
.PARAMETER RoleScopeTagIds
The role scope tag ids of the configuration profile to update.
.PARAMETER Environment
The environment to connect to. Valid values are Global, USGov, USGovDoD. Default is Global.
.EXAMPLE
# Update a configuration profile.
Update-IntuneConfigurationProfile -Id "00000000-0000-0000-0000-000000000000" -Name "MyConfigurationProfile" -Description "My Description" -RoleScopeTagIds @("0")
.EXAMPLE
# Update a configuration profile in the USGov environment.
Update-IntuneConfigurationProfile -Id "00000000-0000-0000-0000-000000000000" -Name "MyConfigurationProfile" -Description "My Description" -RoleScopeTagIds @("0") -Environment USGov
#>
function Update-IntuneConfigurationProfile
{
param (
[Parameter(Mandatory, Position=0, ValueFromPipeline=$true, ValueFromPipelineByPropertyName="id")]
[string]$Id,
[string]$Name,
[string]$Description,
[string[]]$RoleScopeTagIds,
[ValidateSet("Global", "USGov", "USGovDoD")]
[string]$Environment="Global"
)
begin
{
if($false -eq (Initialize-IntuneAccess -Scopes @("DeviceManagementConfiguration.ReadWrite.All") -Modules @("Microsoft.Graph.Authentication") -Environment $Environment))
{
return
}
switch ($Environment) {
"USGov" { $uri = "https://graph.microsoft.us" }
"USGovDoD" { $uri = "https://dod-graph.microsoft.us" }
Default { $uri = "https://graph.microsoft.com" }
}
$graphVersion = "beta"
}
process
{
$currentConfig = Get-IntuneConfigurationProfile -Id $Id -Environment $Environment
$body = @{}
# Only update the name if it was sent
if($Name)
{
$body.name = $Name
}
else
{
$body.name = $currentConfig.name
}
# Only update the description if it was sent
if($Description)
{
$body.description = $Description
}
else
{
$body.description = $currentConfig.description
}
# Only update the roleScopeTagIds if it was sent
if($RoleScopeTagIds)
{
$body.roleScopeTagIds = $RoleScopeTagIds
}
else
{
$body.roleScopeTagIds = $currentConfig.roleScopeTagIds
}
$response = Invoke-MgRestMethod -Method Patch -Uri "$uri/$graphVersion/deviceManagement/configurationPolicies('$Id')" -Body ($body | ConvertTo-Json -Depth 50) -ContentType "application/json" -OutputType Json | ConvertFrom-Json
return $response
}
}
# Write the comment-based HELP for Get-IntuneConfigurationProfileSettings
<#
.SYNOPSIS
Gets a list of Intune configuration profile settings.
.DESCRIPTION
Retrieves a list of configuration profile settings from Intune.
.PARAMETER Id
The id of the configuration profile to retrieve settings for.
.PARAMETER Environment
The environment to connect to. Valid values are Global, USGov, USGovDoD. Default is Global.
.EXAMPLE
# Get all configuration profile settings.
Get-IntuneConfigurationProfileSettings -Id "00000000-0000-0000-0000-000000000000"
.EXAMPLE
# Get all configuration profile settings in the USGov environment.
Get-IntuneConfigurationProfileSettings -Id "00000000-0000-0000-0000-000000000000" -Environment USGov
#>
function Get-IntuneConfigurationProfileSettings
{
param(
[Parameter(Mandatory, ValueFromPipeline=$true, ValueFromPipelineByPropertyName="id", Position=0)]
[string]$Id,
[ValidateSet("Global", "USGov", "USGovDoD")]
[string]$Environment="Global"
)
begin {
if($false -eq (Initialize-IntuneAccess -Scopes @("DeviceManagementConfiguration.Read.All") -Modules @("Microsoft.Graph.Authentication") -Environment $Environment))
{
return
}
switch ($Environment) {
"USGov" { $uri = "https://graph.microsoft.us" }
"USGovDoD" { $uri = "https://dod-graph.microsoft.us" }
Default { $uri = "https://graph.microsoft.com" }
}
$graphVersion = "beta"
}
process {
$response = Invoke-MgRestMethod -Method Get -Uri "$uri/$graphVersion/deviceManagement/configurationPolicies('$Id')/settings" -OutputType Json | ConvertFrom-Json
$settings = @()
foreach($setting in $response.value)
{
$newSetting = [PSCustomObject]@{
"@odata.type" = "#microsoft.graph.deviceManagementConfigurationSetting"
settingInstance = $setting.settingInstance
}
$settings += $newSetting
}
return $settings
}
}