-
Notifications
You must be signed in to change notification settings - Fork 172
/
Documentation.psm1
4012 lines (3494 loc) · 142 KB
/
Documentation.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
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
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<#
Documentation for Intune
This module contains the base documentation function for document objects in Intune
This module will document Settings objects (Settings Catalog, Endpoint Security and Administrative Templates) and
property objects like Configuration Profiles and Comliance Policies
Property objectes are documented based on the ObjectCategories.json file and the json files in the Documentation\ObjectInfo folder.
These json files contains the definition of each property of an object
Settings objects are documented with MS Graph APIs.
A basic Output provider is included that exports the objects to a CSV file
#>
$global:documentationOutput = @()
$global:documentationProviders = @()
function Get-ModuleVersion
{
'1.1.0'
}
function Invoke-InitializeModule
{
# Make sure we add the default Output types
Add-OutputType
$script:columnHeaders = @{
Name="Inputs.displayNameLabel"
Value="TableHeaders.value"
Description="TableHeaders.description"
GroupMode="SettingDetails.modeTableHeader" #assignmentTypeSelectionLabel?
Group="TableHeaders.assignedGroups"
Groups="TableHeaders.groups"
useDeviceContext="SettingDetails.installContextLabel"
uninstallOnDeviceRemoval="SettingDetails.UninstallOnRemoval"
isRemovable="SettingDetails.installAsRemovable"
vpnConfigurationId="PolicyType.vpn"
Action="SettingDetails.actionColumnName"
Schedule="ScheduledAction.List.schedule"
MessageTemplate="ScheduledAction.Notification.messageTemplate"
EmailCC="ScheduledAction.Notification.additionalRecipients"
Filter="AssignmentFilters.assignmentFilterColumnHeader"
Rule="ApplicabilityRules.GridLabel.Rule"
ValueWithLabel="TableHeaders.value"
Status="TableHeaders.status"
CombinedValueWithLabel="TableHeaders.value"
CombinedValue="TableHeaders.value"
useDeviceLicensing="TableHeaders.licenseType"
#filterMode="Filter mode" # Not in any string file yet
}
}
function Invoke-ShowMainWindow
{
$button = [System.Windows.Controls.Button]::new()
$button.Content = "Document"
$button.Name = "btnDocument"
$button.MinWidth = 100
$button.Margin = "0,0,5,0"
$button.IsEnabled = $false
$button.ToolTip = "Document selected objects"
$button.Add_Click({
$objects = ?? ($global:dgObjects.ItemsSource | Where IsSelected -eq $true) $global:dgObjects.SelectedItem
Show-DocumentationForm -Objects $objects
})
$global:spSubMenu.RegisterName($button.Name, $button)
$global:spSubMenu.Children.Insert(0, $button)
}
function Invoke-EMSelectedItemsChanged
{
$hasSelectedItems = ($global:dgObjects.ItemsSource | Where IsSelected -eq $true) -or ($null -ne $global:dgObjects.SelectedItem)
Set-XamlProperty $global:dgObjects.Parent "btnDocument" "IsEnabled" $hasSelectedItems
}
function Invoke-GraphObjectsChanged
{
$btnDocument = $global:spSubMenu.Children | Where-Object { $_.Name -eq "btnDocument" }
$btnExport = $global:spSubMenu.Children | Where-Object { $_.Name -eq "btnExport" }
if($btnDocument -and $btnExport)
{
$btnDocument.Visibility = $btnExport.Visibility
}
}
function Invoke-ViewActivated
{
if($global:currentViewObject.ViewInfo.ID -ne "IntuneGraphAPI") { return }
$tmp = $mnuMain.Items | Where Name -eq "EMBulk"
if($tmp)
{
$tmp.AddChild(([System.Windows.Controls.Separator]::new())) | Out-Null
$subItem = [System.Windows.Controls.MenuItem]::new()
$subItem.Header = "_Document Types"
$subItem.Add_Click({Invoke-DocumentObjectTypes})
$tmp.AddChild($subItem)
$subItem = [System.Windows.Controls.MenuItem]::new()
$subItem.Header = "D_ocument Selected"
$subItem.Add_Click({Invoke-DocumentSelectedObjects})
$tmp.AddChild($subItem)
}
}
function Set-DocColumnHeaderLanguageId
{
param($columnName, $lngId)
if(-not $script:columnHeaders -or -not $lngId) { return }
if($script:columnHeaders.ContainsKey($columnName))
{
$script:columnHeaders[$columnName] = $lngId
}
else
{
$script:columnHeaders.Add($columnName, $lngId)
}
}
function Invoke-DocTranslateColumnHeader
{
param($columnName)
$lngText = ""
if($script:columnHeaders.ContainsKey($columnName))
{
$lngText = Get-LanguageString $script:columnHeaders[$columnName]
}
(?? $lngText $columnName)
}
function Add-OutputType
{
param($outputInfo)
if(-not $global:documentationOutput)
{
$global:documentationOutput = @()
}
if($global:documentationOutput.Count -eq 0)
{
$global:documentationOutput += [PSCustomObject]@{
Name = "None (Raw output only)"
Value = "none"
}
$global:documentationOutput += [PSCustomObject]@{
Name="CSV"
Value="csv"
OutputOptions = (Add-CSVOptionsControl)
Activate = { Invoke-CSVActivate @args }
PreProcess = { Invoke-CSVPreProcessItems @args }
Process = { Invoke-CSVProcessItem @args }
}
}
if(!$outputInfo) { return }
$global:documentationOutput += $outputInfo
}
function Add-DocumentationProvicer
{
param($docProvider)
if(-not $global:documentationProviders)
{
$global:documentationProviders = @()
}
$global:documentationProviders += $docProvider
}
function Get-ObjectDocumentation
{
param($documentationObj)
$additionalInfo = ""
if($documentationObj.Object.'@ObjectFromFile' -eq $true)
{
$additionalInfo = " - From File"
}
Write-Status "Get documentation info for $((Get-GraphObjectName $documentationObj.Object $documentationObj.ObjectType)) ($($documentationObj.ObjectType.Title))$additionalInfo"
$status = $null
$inputType = "Settings"
if(-not $script:scopeTags)
{
$script:scopeTags = (Invoke-GraphRequest -Url "/deviceManagement/roleScopeTags").Value
}
$obj = $documentationObj.Object
$objectType = $documentationObj.ObjectType
$script:currentObject = $obj
$script:languageStrings = $null
$script:CurrentSubCategory = $null
$script:objectBasicInfo = @()
$script:objectSettingsData = @()
$script:objectComplianceActionData = @()
$script:applicabilityRules = @()
$script:objectAssignments = @()
$updateFilteredObject = $true
$type = $obj.'@OData.Type'
$defaultDocumentationProperties = @("Name","Value")
$retObj = $null
foreach($docProvider in ($global:documentationProviders | Sort -Property Priority))
{
if($docProvider.DocumentObject)
{
$retObj = & $docProvider.DocumentObject $documentationObj
if($retObj -ne $null)
{
break
}
}
}
$propertyObjectProperties = @("Name","Value","Category","SubCategory","RawValue","RawJsonValue","DefaultValue","UnconfiguredValue","EntityKey","Description","Enabled")
#region Custom documentation
if($retObj)
{
$status = $retObj.ErrorText
$properties = $retObj.Properties
$inputType = ?? $retObj.InputType "Property"
$defaultDocumentationProperties = ?? $retObj.DefaultDocumentationProperties $defaultDocumentationProperties
}
#endregion
#region Manually created file - ODataType
elseif([IO.File]::Exists(($global:AppRootFolder + "\Documentation\ObjectInfo\$($obj.'@OData.Type').json")))
{
$inputType = "Property"
# Process object based on OData type
Invoke-TranslateCustomProfileObject $obj "$($obj.'@OData.Type')" | Out-Null
$properties = $propertyObjectProperties
}
#endregion
#region Manually created file - ObjectType id
elseif($objectType -and [IO.File]::Exists(($global:AppRootFolder + "\Documentation\ObjectInfo\#$($objectType.Id).json")))
{
$inputType = "Property"
# Process object based on Intune Object Type ($objectType)
# '#' is added to front of name to distinguish manually created files from generated files
Invoke-TranslateCustomProfileObject $obj "#$($objectType.Id)" | Out-Null
$properties = $propertyObjectProperties
}
#endregion
#region Settings Catalog
elseif($type -eq "#microsoft.graph.deviceManagementConfigurationPolicy")
{
Invoke-TranslateSettingsObject $obj $objectType | Out-Null
$properties = @("Name","Value","RootCategory","Category","RawValue","RawJsonValue","DefaultValue","Description")
}
#endregion
#region Endpoint Security
elseif($type -eq "#microsoft.graph.deviceManagementIntent")
{
Invoke-TranslateIntentObject $obj $objectType | Out-Null
$properties = @("Name","Value","Category","RawValue","SettingId","Description")
}
#endregion
#region Administrative Templates
elseif($type -eq "#microsoft.graph.groupPolicyConfiguration")
{
Invoke-TranslateADMXObject $obj $objectType | Out-Null
$properties = @("Name","Status","Value","Category","CategoryPath","RawValue","ValueWithLabel","Created","Modified", "Class", "DefinitionId")
$defaultDocumentationProperties = @("Name","Status","Value")
$updateFilteredObject = $false
$inputType = "Property"
}
#endregion
#region Profile Types e.g. DeviceConfiguration Policies etc
elseif($type)
{
$inputType = "Property"
$processed = $true
$processed = Invoke-TranslateProfileObject $obj
if($processed -eq $false)
{
$errText = "No object file or object info found for $((Get-GraphObjectName $obj $objType)) ($($obj.'@OData.Type'))`n`nObject type not supported for documentation"
# Object not processed
$status = $errText
Write-Log $errText 3
}
$properties = $propertyObjectProperties
}
#endregion
if($script:objectBasicInfo.Count -gt 0)
{
Add-ScopeTagStrings $obj
}
if($obj.scheduledActionsForRule.scheduledActionConfigurations)
{
Invoke-TranslateScheduledActionType $obj.scheduledActionsForRule
}
if(($obj.assignments | measure).Count -gt 0)
{
Invoke-TranslateAssignments $obj
}
$script:settingsProperties = $properties
[PSCustomObject]@{
BasicInfo = $script:objectBasicInfo
Settings = $script:objectSettingsData
ComplianceActions = $script:objectComplianceActionData
ApplicabilityRules = $script:applicabilityRules
Assignments = $script:objectAssignments
DisplayProperties = $properties
DefaultDocumentationProperties = $defaultDocumentationProperties
ErrorText = $status
InputType = $inputType
UpdateFilteredObject = $updateFilteredObject
UnconfiguredProperties = $obj."@UnconfiguredProperties"
}
}
function Get-DocumentedSettings
{
$script:objectSettingsData
}
function Invoke-ObjectDocumentation
{
param($documentationObj)
$global:intentCategories = $null
$global:catRecommendedSettings = $null
$global:intentCategoryDefs = $null
$global:cfgCategories = $null
$script:DocumentationLanguage = "en"
$script:objectSeparator = [System.Environment]::NewLine
$script:propertySeparator = ","
Get-ObjectDocumentation $documentationObj
}
function Add-RawDataInfo
{
param($obj, $objectType)
$params = @{}
if($txtDocumentationRawData.Text)
{
$txtDocumentationRawData.Text += "`n`n"
}
$txtDocumentationRawData.Text += "#########################################################"
$txtDocumentationRawData.Text += "`n`n# Object: $((Get-GraphObjectName $obj $objectType))"
$txtDocumentationRawData.Text += "`n# Type: $($obj.'@OData.Type')"
$txtDocumentationRawData.Text += "`n`n#########################################################"
if($script:objectBasicInfo.Count -gt 0)
{
$txtDocumentationRawData.Text += "`n`n# Basic Info`n`n"
$txtDocumentationRawData.Text += (($script:objectBasicInfo | Select -Property Name,Value | ConvertTo-Csv -NoTypeInformation @params) -join ([System.Environment]::NewLine))
}
if($script:objectSettingsData)
{
$txtDocumentationRawData.Text += "`n`n# Object Settings`n`n"
$txtDocumentationRawData.Text += (($script:objectSettingsData | Select -Property $script:settingsProperties | ConvertTo-Csv -NoTypeInformation @params) -join ([System.Environment]::NewLine))
}
if(($documentedObj.ApplicabilityRules | measure).Count -gt 0)
{
$txtDocumentationRawData.Text += "`n`n# Applicability rules`n`n"
$txtDocumentationRawData.Text += (($script:applicabilityRules | Select Rule,Property,Value,Category | ConvertTo-Csv -NoTypeInformation) -join ([System.Environment]::NewLine))
}
if($script:objectComplianceActionData.Count -gt 0)
{
$txtDocumentationRawData.Text += "`n`n# Compliance actions`n`n"
$txtDocumentationRawData.Text += (($script:objectComplianceActionData | Select Action,Schedule,MessageTemplate,EmailCC,Category | ConvertTo-Csv -NoTypeInformation) -join ([System.Environment]::NewLine))
}
if($script:objectAssignments.Count -gt 0)
{
if($script:objectAssignments.Count -gt 0 -and $script:objectAssignments[0].RawIntent)
{
$properties = @("GroupMode","Group","Filter","FilterMode","Category","SubCategory","RawIntent")
}
else
{
$properties = @("GroupMode","Group","Filter","FilterMode","Category")
}
$txtDocumentationRawData.Text += "`n`n# Assignments`n`n"
$txtDocumentationRawData.Text += (($script:objectAssignments | Select -Property $properties | ConvertTo-Csv -NoTypeInformation) -join ([System.Environment]::NewLine))
}
}
function Get-ObjectTypeString
{
param($obj, $objectType)
$objTypeId = ?? $objectType.GroupId $objectType
if($objTypeId -eq "DeviceConfiguration")
{
return (Get-LanguageString "SettingDetails.deviceConfigurationTitle")
}
elseif($objTypeId -eq "CompliancePolicies")
{
return (Get-LanguageString "SettingDetails.deviceComplianceTitle")
}
elseif($objTypeId -eq "Apps")
{
return (Get-LanguageString "SettingDetails.clientAppsTitle")
}
elseif($objTypeId -eq "WinEnrollment")
{
return (Get-LanguageString "SettingDetails.windowsEnrollmentTitle")
}
elseif($objTypeId -eq "AppleEnrollment")
{
return (Get-LanguageString "SettingDetails.appleEnrollmentTitle")
}
elseif($objTypeId -eq "PolicySets")
{
return (Get-LanguageString "SettingDetails.policySetsTitle")
}
elseif($objTypeId -eq "AppConfiguration")
{
return (Get-LanguageString "SettingDetails.appConfiguration")
}
elseif($objTypeId -eq "AppProtection")
{
return (Get-LanguageString "SettingDetails.appProtectionPolicy")
}
elseif($objTypeId -eq "CustomAttributes")
{
return (Get-LanguageString "Titles.customAttributes")
}
elseif($objTypeId -eq "ConditionalAccess")
{
return (Get-LanguageString "SecurityTemplate.conditionalAccess")
}
elseif($objTypeId -eq "EndpointAnalytics")
{
return (Get-LanguageString "SettingDetails.healthMonScopeBootPerf")
}
elseif($objTypeId -eq "EndpointSecurity")
{
return (Get-LanguageString "PolicyType.EndpointSecurityTemplate.default")
}
elseif($objTypeId -eq "EnrollmentRestrictions")
{
return (Get-LanguageString "Titles.enrollmentRestrictions")
}
elseif($objTypeId -eq "Scripts")
{
return (Get-LanguageString "Titles.scriptManagement")
}
elseif($objTypeId -eq "WinUpdatePolicies")
{
return (Get-LanguageString "Titles.windows10UpdateRings")
}
elseif($objTypeId -eq "WinFeatureUpdates")
{
return (Get-LanguageString "Titles.featureUpdateDeployments")
}
elseif($objTypeId -eq "WinQualityUpdates")
{
return (Get-LanguageString "Titles.windows10QualityUpdate")
}
elseif($objTypeId -eq "TenantAdmin")
{
return (Get-LanguageString "Titles.tenantAdmin")
}
elseif($objTypeId -eq "Azure")
{
return "Azure"
}
}
function Add-BasicDefaultValues
{
param($obj, $objectType)
Add-BasicPropertyValue (Get-LanguageString "SettingDetails.nameName") (Get-GraphObjectName $obj $objectType)
Add-BasicPropertyValue (Get-LanguageString "SettingDetails.descriptionName") $obj.description
$objInfo = Get-TranslationFiles $obj.'@OData.Type'
$appType = Get-GraphAppType $obj
if($objInfo)
{
$platformType = Get-LanguageString "Platform.$($objInfo.PlatformLanguageId)"
$profileType = Get-LanguageString "ConfigurationTypes.$($objInfo.PolicyType)"
if($platformType) { Add-BasicPropertyValue (Get-LanguageString "SettingDetails.platformSupported") $platformType }
if($profileType) { Add-BasicPropertyValue (Get-LanguageString "TableHeaders.configurationType") $profileType }
}
if($appType)
{
$appTypeName = Get-LanguageString "AppType.$($appType.LanguageId)"
if($appTypeName) { Add-BasicPropertyValue (Get-LanguageString "Inputs.installationSourceLabel") $appTypeName }
}
if($obj."@OData.Type" -eq "#microsoft.graph.deviceManagementIntent")
{
if(-not $script:baseLineTemplates)
{
$script:baseLineTemplates = (Invoke-GraphRequest -Url "/deviceManagement/templates").Value
}
$baseLineTemplate = $script:baseLineTemplates | Where Id -eq $obj.templateId
if(-not $baseLineTemplate)
{
Write-Log "Could not find Baseline Template with Id $($obj.templateId)" 3
}
$platformType = Get-LanguageString "Platform.$($baseLineTemplate.platformType)"
if($platformType) { Add-BasicPropertyValue (Get-LanguageString "SettingDetails.platformSupported") $platformType }
Add-BasicPropertyValue (Get-LanguageString "TableHeaders.Category") (Get-IntentCategory (?: ($baseLineTemplate.templateSubtype -eq "none") $baseLineTemplate.templateType $baseLineTemplate.templateSubtype))
Add-BasicPropertyValue (Get-LanguageString "TableHeaders.policyType") $baseLineTemplate.displayName
}
if($obj.deviceManagementApplicabilityRuleDeviceMode)
{
# Future setting?
}
if($obj.deviceManagementApplicabilityRuleOsEdition)
{
$arrOSList = @()
foreach($os in $obj.deviceManagementApplicabilityRuleOsEdition.osEditionTypes)
{
$arrOSList += Get-LanguageString "ApplicabilityRules.$os"
}
$script:applicabilityRules += [PSCustomObject]@{
Rule = Get-LanguageString "ApplicabilityRules.$((?: ($obj.deviceManagementApplicabilityRuleOsEdition.ruleType -eq "exclude") "dontAssignIf" "assignIf"))"
Property = Get-LanguageString "ApplicabilityRules.windows10OsEdition"
Value = $arrOSList -join $script:objectSeparator
Id = "deviceManagementApplicabilityRuleOsEdition"
Category = Get-LanguageString "SettingDetails.applicabilityRules"
}
}
if($obj.deviceManagementApplicabilityRuleOsVersion)
{
$script:applicabilityRules += [PSCustomObject]@{
Rule = Get-LanguageString "ApplicabilityRules.$((?: ($obj.deviceManagementApplicabilityRuleOsVersion.ruleType -eq "exclude") "dontAssignIf" "assignIf"))"
Property = Get-LanguageString "ApplicabilityRules.windows10OsVersion"
Value = "$($obj.deviceManagementApplicabilityRuleOsVersion.minOSVersion) $((Get-LanguageString "ApplicabilityRules.toText")) $($obj.deviceManagementApplicabilityRuleOsVersion.maxOSVersion)"
Id = "deviceManagementApplicabilityRuleOsVersion"
Category = Get-LanguageString "SettingDetails.applicabilityRules"
}
}
}
function Add-BasicAdditionalValues
{
param($obj, $objectType)
if($obj.createdDateTime)
{
$tmpDate = ([DateTime]::Parse($obj.createdDateTime))
Add-BasicPropertyValue (Get-LanguageString "Inputs.createdDateTime") "$($tmpDate.ToLongDateString()) $($tmpDate.ToLongTimeString())"
}
if($obj.lastModifiedDateTime)
{
$tmpDate = ([DateTime]::Parse($obj.lastModifiedDateTime))
Add-BasicPropertyValue (Get-LanguageString "TableHeaders.lastModified") "$($tmpDate.ToLongDateString()) $($tmpDate.ToLongTimeString())"
}
elseif($obj.modifiedDateTime)
{
$tmpDate = ([DateTime]::Parse($obj.modifiedDateTime))
Add-BasicPropertyValue (Get-LanguageString "TableHeaders.lastModified") "$($tmpDate.ToLongDateString()) $($tmpDate.ToLongTimeString())"
}
if($obj.version)
{
Add-BasicPropertyValue (Get-LanguageString "SettingDetails.eDPPolicyAppsListVersionName") $obj.version
}
#Add-BasicPropertyValue (Get-LanguageString "TableHeaders.type") $obj.'@OData.Type'
}
function Add-BasicPropertyValue
{
param($name, $value)
$script:objectBasicInfo += [PSCustomObject]@{
Name=$name
Value=$value
Category=(Get-LanguageString "SettingDetails.basics")
}
}
function Add-ScopeTagStrings
{
param($obj)
$objScopeTags = @()
if(($obj.roleScopeTagIds | measure).Count -gt 0)
{
foreach($scopeTagId in $obj.roleScopeTagIds)
{
$scopeTagName = $scopeTagId
if($scopeTagId -eq "0")
{
$scopeTagName = (Get-LanguageString "SettingDetails.default")
}
elseif($script:scopeTags)
{
$scopeTagObj = $script:scopeTags | Where Id -eq $scopeTagId
if($scopeTagObj.displayName)
{
$scopeTagName = $scopeTagObj.displayName
}
}
$objScopeTags += $scopeTagName
}
}
if($objScopeTags.Count -gt 0)
{
Add-BasicPropertyValue (Get-LanguageString "TableHeaders.scopeTags") ($objScopeTags -join $script:objectSeparator)
}
}
function Get-ObjectPlatformFromType
{
param($obj)
$platform = $null
$lowerAppType = $obj.'@OData.Type'.ToLower()
if($lowerAppType.Contains("ios"))
{
$platform = "iOS"
}
elseif($lowerAppType.Contains("mac"))
{
$platform = "Mac"
}
elseif($lowerAppType.Contains("windowsphone"))
{
$platform = "WindowsPhone"
}
elseif($lowerAppType.Contains("windows") -or $lowerAppType.Contains("win32") -or $lowerAppType.Contains("mirosoftstore"))
{
$platform = "Windows10"
}
elseif($lowerAppType.Contains("android"))
{
$platform = "Android"
}
$platform
}
#region Admin Templates
function Invoke-TranslateADMXObject
{
param($obj, $objectType)
Add-BasicDefaultValues $obj $objectType
Add-BasicPropertyValue (Get-LanguageString "TableHeaders.configurationType") (Get-LanguageString "Titles.groupPolicy")
#Add-BasicPropertyValue (Get-LanguageString "SettingDetails.platformSupported") $platformType
Add-BasicAdditionalValues $obj $objectType
$params = @{}
## Set language
if($script:DocumentationLanguage)
{
$params.Add("AdditionalHeaders", @{"Accept-Language"=$script:DocumentationLanguage})
}
if(-not $script:admxCategories)
{
$script:admxCategories = (Invoke-GraphRequest "deviceManagement/groupPolicyCategories?`$expand=parent(`$select=id, displayName, isRoot),definitions(`$select=id, displayName, categoryPath, classType, policyType)&`$select=id, displayName, isRoot" -ODataMetadata "skip" @params).value
}
if(!$obj.definitionValues)
{
$definitionValues = (Invoke-GraphRequest "deviceManagement/groupPolicyConfigurations('$($obj.Id)')/definitionValues?`$expand=definition(`$select=id,classType,displayName,policyType,groupPolicyCategoryId)" -ODataMetadata "minimal").value
}
else
{
# Documenting exported json
$definitionValues = $obj.definitionValues
}
$enabledStr = Get-LanguageString "Inputs.enabled"
$disabledStr = Get-LanguageString "Inputs.disabled"
foreach($definitionValue in $definitionValues)
{
if(-not $definitionValue.definition -and $definitionValues.'definition@odata.bind')
{
$definition = Invoke-GraphRequest -Url $definitionValue.'definition@odata.bind' -ODataMetadata "minimal" @params
if($definition)
{
$definitionValue | Add-Member -MemberType NoteProperty -Name "definition" -Value $definition
}
}
$categoryObj = $script:admxCategories | Where { $definitionValue.definition.id -in ($_.definitions.id) }
$category = $script:admxCategories.definitions | Where { $definitionValue.definition.id -in ($_.id) }
# Get presentation values for the current settings (with presentation object included)
if($definitionValue.presentationValues -or $obj.'@ObjectFromFile' -eq $true) #$definitionValue.'definition@odata.bind')
{
# Documenting exported json
#$presentationValues = (Invoke-GraphRequest -Url "$($definitionValue.'definition@odata.bind')/presentations?`$expand=presentation" -ODataMetadata "minimal").value
$presentationValues = $definitionValue.presentationValues
}
elseif($definitionValue.id)
{
$presentationValues = (Invoke-GraphRequest -Url "/deviceManagement/groupPolicyConfigurations/$($obj.id)/definitionValues/$($definitionValue.id)/presentationValues?`$expand=presentation" -ODataMetadata "minimal" @params).value
}
else
{
$presentationValues = $null
}
$value = $null
$rawValues = @()
$values = @()
$valuesWithLabel = @()
foreach($presentationValue in $presentationValues)
{
if(-not $presentationValue.presentation -and $presentationValue.'presentation@odata.bind')
{
$presentation = Invoke-GraphRequest -Url $presentationValue.'presentation@odata.bind'
if($presentation)
{
$presentationValue | Add-Member -MemberType NoteProperty -Name "presentation" -Value $presentation
}
}
$rawValue = $presentationValue.value
$label = $presentationValue.presentation.label
$value = $null
if($presentationValue.presentation.'@odata.type' -eq '#microsoft.graph.groupPolicyPresentationDropdownList')
{
$value = ($presentationValue.presentation.items | Where value -eq $rawValue).displayName
}
elseif($presentationValue.'@odata.type' -eq '#microsoft.graph.groupPolicyPresentationValueList')
{
$arrValues = @()
foreach($tmpValue in $presentationValue.values)
{
$arrValues += ($tmpValue.name + $script:propertySeparator + $tmpValue.value)
}
$value = $arrValues -join $script:objectSeparator
}
elseif($presentationValue.'@odata.type' -eq '#microsoft.graph.groupPolicyPresentationValueMultiText')
{
$value = $presentationValue.values -join $script:objectSeparator
}
else
{
#groupPolicyPresentationValueBoolean
#groupPolicyPresentationValueDecimal
#groupPolicyPresentationValueLongDecimal
#groupPolicyPresentationValueText
$value = $rawValue
}
$valuesWithLabel += "$label $value"
$values += $value
$rawValues += $rawValue
}
$status = (?: ($definitionValue.enabled -eq $true) $enabledStr $disabledStr)
$script:objectSettingsData += New-Object PSObject -Property @{
Name = $definitionValue.definition.displayName
Description = $definitionValue.definition.explainText
Status = $status
Value = $values -join $script:objectSeparator
CombinedValue = ($status + $script:objectSeparator + ($values -join $script:objectSeparator))
ValueWithLabel = $valuesWithLabel -join $script:objectSeparator
CombinedValueWithLabel = ($status + $script:objectSeparator + ($valuesWithLabel -join $script:objectSeparator))
RawValue = $rawValues -join $script:propertySeparator
Class = $definitionValue.definition.classType
DefinitionId = $definitionValue.definition.id
Created = $definitionValue.createdDateTime
Modified = $definitionValue.lastModifiedDateTime
#Category = $categoryObj.displayName
Category = $category.categoryPath
CategoryPath = $category.categoryPath
EntityKey = $definitionValue.definition.id # Required for Compare
}
}
$script:objectSettingsData = $script:objectSettingsData | Sort -Property CategoryPath
}
#endregion
#region Settings Catalog
function Invoke-TranslateSettingsObject
{
param($obj, $objectType)
$platformType = Get-LanguageString "Platform.$($obj.platforms)"
Add-BasicDefaultValues $obj $objectType
Add-BasicPropertyValue (Get-LanguageString "TableHeaders.configurationType") (Get-LanguageString "ConfigurationTypes.settingsCatalog")
Add-BasicPropertyValue (Get-LanguageString "SettingDetails.platformSupported") $platformType
Add-BasicAdditionalValues $obj $objectType
$params = @{}
## Set language
if($script:DocumentationLanguage)
{
$params.Add("AdditionalHeaders", @{"Accept-Language"=$script:DocumentationLanguage})
}
$cfgSettings = (Invoke-GraphRequest "/deviceManagement/configurationPolicies('$($obj.Id)')/settings?`$expand=settingDefinitions&top=1000" -ODataMetadata "minimal" @params).Value
if(-not $global:cfgCategories)
{
$global:cfgCategories = (Invoke-GraphRequest "/deviceManagement/configurationCategories?`$filter=platforms has 'windows10' and technologies has 'mdm'" -ODataMetadata "minimal" @params).Value
}
$categories = @{}
foreach($cfgSetting in $cfgSettings)
{
$defObj = $cfgSetting.settingDefinitions | Where id -eq $cfgSetting.settingInstance.settingDefinitionId
if(-not $defObj -or $categories.ContainsKey($defObj.categoryId)) { continue }
$catObj = $global:cfgCategories | Where Id -eq $defObj.categoryId
$rootCatObj = $global:cfgCategories | Where Id -eq $catObj.rootCategoryId
$catSettings = Invoke-GraphRequest "/deviceManagement/configurationSettings?`$filter=categoryId eq '$($defObj.categoryId)' and applicability/platform has 'windows10' and applicability/technologies has 'mdm'" -ODataMetadata "minimal" @params
$categories.Add($defObj.categoryId, (New-Object PSObject -Property @{
Category=$catObj
Settings=$catSettings
RootCategory=$rootCatObj
}))
}
Add-SettingsSetting $obj $objectType $categories $cfgSettings
}
function Add-SettingsSetting
{
param($obj, $objectType, $categories, $cfgSettings, $settigsDefs = $null)
foreach($cfgSetting in $cfgSettings)
{
$children = $null
$skipAdd = $false
$cfgInstance = ?? $cfgSetting.settingInstance $cfgSetting
if($cfgSetting.settingDefinitions)
{
$settigsDefs = $cfgSetting.settingDefinitions
}
$defaultValue = $null
$rawValue=$null
$rawJsonValue = $null
$defObj = $settigsDefs | Where id -eq $cfgInstance.settingDefinitionId
$catObj = $categories[$defObj.categoryId]
if($cfgInstance.'@odata.type' -eq '#microsoft.graph.deviceManagementConfigurationChoiceSettingInstance')
{
$rawValue = $cfgInstance.choiceSettingValue.value
$itemValue = ($defObj.Options | Where itemId -eq $rawValue).displayName
if($defObj.defaultOptionId)
{
$defaultValue = ($defObj.Options | Where itemId -eq $defObj.defaultOptionId).displayName
}
$children = $cfgInstance.choiceSettingValue.children
}
elseif($cfgInstance.'@odata.type' -eq '#microsoft.graph.deviceManagementConfigurationChoiceSettingCollectionInstance')
{
$itemValues = @()
$itemRawValues = @()
foreach($colObj in $cfgInstance.simpleSettingCollectionValue)
{
$tmpValue = $colObj.value
$itemValues += ($defObj.Options | Where itemId -eq $tmpValue).displayName
$itemRawValues += $tmpValue
}
$rawValue = $itemValues -join $script:propertySeparator
$itemValue = $itemRawValues -join $script:propertySeparator
if($defObj.defaultOptionId)
{
$defaultValue = ($defObj.Options | Where itemId -eq $defObj.defaultOptionId).displayName
}
}
elseif($cfgInstance.'@odata.type' -eq '#microsoft.graph.deviceManagementConfigurationSimpleSettingInstance')
{
$itemValue = $cfgInstance.simpleSettingValue.value
$rawValue = $itemValue
if($defObj.defaultValue.value)
{
$defaultValue = $defObj.defaultValue.value
}
}
elseif($cfgInstance.'@odata.type' -eq '#microsoft.graph.deviceManagementConfigurationSimpleSettingCollectionInstance')
{
$itemValues = @()
$rawValue = $cfgInstance.simpleSettingCollectionValue
foreach($colObj in $cfgInstance.simpleSettingCollectionValue)
{
$itemValues += $colObj.value
}
if($defObj.defaultValue.value)
{
$defaultValue = $defObj.defaultValue.value
}
$itemValue = $itemValues -join $script:propertySeparator
}
elseif($cfgInstance.'@odata.type' -eq '#microsoft.graph.deviceManagementConfigurationGroupSettingInstance')
{
# This will skip adding the group itself as enabled...
# It will only add information about the children
Add-SettingsSetting $obj $objectType $categories $cfgInstance.groupSettingValue.children $settigsDefs
continue
}
elseif($cfgInstance.'@odata.type' -eq '#microsoft.graph.deviceManagementConfigurationGroupSettingCollectionInstance')
{
# ToDo: Fix support for other child types
# This assumes that all children are deviceManagementConfigurationSimpleSettingInstance
$objItems = @()
foreach($childObj in $cfgInstance.groupSettingCollectionValue)
{
$objProps = @()
foreach($childId in $defObj.childIds)
{
$childSetting = $childObj.children | Where settingDefinitionId -eq $childId
if($childSetting)
{
$objProps += $childSetting.simpleSettingValue.value
}
}
$objItems += $objProps -join $script:propertySeparator
}
$itemValue = $objItems -join $script:objectSeparator
$rawValue = $itemValue
$rawJsonValue = $cfgInstance.groupSettingCollectionValue | ConvertTo-Json -Depth 20 -Compress
}
else
{
Write-Log "Unsupported setting type: $($cfgInstance.'@odata.type')"
}
if(!$rawJsonValue -and $rawValue)
{
$rawJsonValue = $rawValue | ConvertTo-Json -Depth 20 -Compress
}
$script:objectSettingsData += New-Object PSObject -Property @{
Name=$defObj.displayName
Description=$defObj.description
Category=$catObj.Category.displayName
CategoryDescription=$catObj.Category.description
Value=$itemValue
RawValue=$rawValue
RawJsonValue=$rawJsonValue
DefaultValue=$defaultValue
RootCategory=$catObj.RootCategory.displayName
CategoryObject=$catObj
SettingId=$cfgInstance.settingDefinitionId
}