-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathComplianceUtility.psm1
5156 lines (3466 loc) · 232 KB
/
ComplianceUtility.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
#Requires -Version 5.1
# Copyright (c) Microsoft Corporation
# Licensed under the MIT License
<# Variables #>
$Global:strVersion = "3.2.1" <# Version #>
$Global:strDefaultWindowTitle = $Host.UI.RawUI.WindowTitle <# Caching window title #>
$Global:host.UI.RawUI.WindowTitle = "Compliance Utility ($Global:strVersion)" <# Set window title #>
$Global:bolMenuCollectExtended = $false <# Variable for COLLECT menu handling #>
$Global:bolCommingFromMenu = $false <# Variable for menu handling inside functions #>
$Global:bolSkipRequiredUpdates = $false <# Variable for handling updates #>
$Global:FormatEnumerationLimit = -1 <# Variable to show full Format-List for arrays #>
Function fncInitialize{
<# Variable for user log path #>
$Global:strUserLogPath | Out-Null
<# Detect Windows #>
If ([System.Environment]::OSVersion.Platform -eq "Win32NT") {
<# Variable for Windows version #>
$Global:strOSVersion = (Get-CimInstance Win32_OperatingSystem).Caption
<# Check for supported Windows versions #>
If ($Global:strOSVersion -like "*Windows 10*" -Or
$Global:strOSVersion -like "*Windows 11*" -Or
$Global:strOSVersion -like "*2012*" -Or
$Global:strOSVersion -like "*Server 2016*" -Or
$Global:strOSVersion -like "*Server 2019*" -Or
$Global:strOSVersion -like "*Server 2022*"){
<# Variables #>
$Global:strTempFolder = (Get-Item Env:"Temp").Value <# User temp folder #>
$Global:strUserLogPath = New-Item -ItemType Directory -Force -Path "$Global:strTempFolder\ComplianceUtility" <# Default user log path #>
$Global:bolRunningPrivileged = [bool](([System.Security.Principal.WindowsIdentity]::GetCurrent()).Groups -match "S-1-5-32-544") <# Control variable for privilege checks #>
}
Else { <# Actions, when running on unsupported Windows #>
<# Variable #>
$Global:strOSVersion = $null
<# Logging #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "Unsupported operating system" -strLogValue $true
<# Output #>
Write-ColoredOutput Red "ATTENTION: The 'Compliance Utility' does not support the operating system you're using.`nPlease ensure to use one of the following supported operating systems:`nMicrosoft Windows 11, Windows 10, Windows Server 2022, Windows Server 2019, Windows Server 2016, and Windows Server 2012/R2.`n"
<# Set back window title #>
$Global:host.UI.RawUI.WindowTitle = $Global:strDefaultWindowTitle
<# Exit #>
Break
}
<# Logging Windows edition and version #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "OS edition" -strLogValue $Global:strOSVersion
fncLogging -strLogFunction "fncInitialize" -strLogDescription "OS version" -strLogValue $([System.Environment]::OSVersion.Version)
}
<# Detect macOS #>
If ($IsMacOS -eq $true) {
<# Variables #>
$Global:strOSVersion = $(sw_vers -productVersion) <# Apple macOS version #>
<# Check for unsupported macOS #>
If ($Global:strOSVersion -lt "12.5") {
<# Variable #>
$Global:strOSVersion = $null
<# Logging #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "Unsupported operating system" -strLogValue $true
<# Output #>
Write-ColoredOutput Red "ATTENTION: The 'Compliance Utility' does not support the operating system you're using.`nPlease ensure to use a supported operating system:`nApple macOS 12.5 (Monterey) or higher.`n"
<# Set back window title #>
$Global:host.UI.RawUI.WindowTitle = $Global:strDefaultWindowTitle
<# Exit #>
Break
}
Else { <# Actions on supported macOS versions #>
<# Variable #>
$Global:strUserLogPath = New-Item -ItemType Directory -Force -Path "$(printenv HOME)\Documents\ComplianceUtility" <# Default user log path #>
<# Detect if user is in admin group (80) #>
If ($(id -G) -match "80"){
<# Control variable for privileges checks #>
$Global:bolRunningPrivileged = $true
}
Else {
<# Control variable for privileges checks #>
$Global:bolRunningPrivileged = $false
}
}
<# Logging: macOS #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "OS edition" -strLogValue "Apple $(sw_vers -productName) ($(uname -s))"
fncLogging -strLogFunction "fncInitialize" -strLogDescription "OS version" -strLogValue $Global:strOSVersion
fncLogging -strLogFunction "fncInitialize" -strLogDescription "OS kernel" -strLogValue $(uname -v)
}
<# Logging: Default entries for Windows and macOS #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "OS 64-Bit" -strLogValue $([System.Environment]::Is64BitOperatingSystem) <# Architecture #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "Module version" -strLogValue "$Global:strVersion" <# Module version #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "Username" -strLogValue $([System.Environment]::UserName) <# Username #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "Machine name" -strLogValue $([System.Environment]::MachineName) <# Machine name #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "PowerShell Host" -strLogValue $($Host.Name.ToString()) <# PowerShell host #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "PowerShell Version" -strLogValue $($Host.Version.ToString()) <# PowerShell version #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "PowerShell Edition" -strLogValue $($PSVersionTable.PSEdition.ToString()) <# PowerShell edition #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "PowerShell Current culture" -strLogValue $($Host.CurrentCulture.ToString()) <# PowerShell culture #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "PowerShell Current UI culture" -strLogValue $($Host.CurrentUICulture.ToString()) <# PowerShell UI culture #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "Running privileged" -strLogValue $Global:bolRunningPrivileged <# Administrative privileges #>
<# Variable to check for unsupported PowerShell #>
$Global:bolSupportedPowerShell | Out-Null
$Global:bolSupportedPowerShell = $true
<# Detect PowerShell Destkop 5.1 #>
If ($PSVersionTable.PSEdition.ToString() -eq "Desktop" -and [Version]::new($PSVersionTable.PSVersion.Major, $PSVersionTable.PSVersion.Minor) -ne [Version]::new("5.1")) {
<# Set unsupported PowerShell #>
$Global:bolSupportedPowerShell = $false
}
<# Detect PowerShell Core 7.4 (or less) #>
If ($PSVersionTable.PSEdition.ToString() -eq "Core" -and [Version]::new($PSVersionTable.PSVersion.Major, $PSVersionTable.PSVersion.Minor) -lt [Version]::new("7.4")) {
<# Set unsupported PowerShell #>
$Global:bolSupportedPowerShell = $false
}
<# Check for supported PowerShell #>
If ($Global:bolSupportedPowerShell -eq $false) {
<# Logging #>
fncLogging -strLogFunction "fncInitialize" -strLogDescription "Supported PowerShell version" -strLogValue $false
<# Output #>
Write-ColoredOutput Red "ATTENTION: The version of PowerShell that is required by the 'Compliance Utility' does not match the currently running version of PowerShell $($PSVersionTable.PSVersion).`n"
<# Set back window title to default #>
$Global:host.UI.RawUI.WindowTitle = $Global:strDefaultWindowTitle
<# Exit #>
Break
}
<# Release variable #>
$Global:bolSupportedPowerShell = $null
}
<# Core definitions #>
Function ComplianceUtility {
<#
.SYNOPSIS
The 'Compliance Utility' is a powerful tool that helps troubleshoot and diagnose sensitivity labels, policies, settings and more. Whether you need to fix issues or reset configurations, this tool has you covered.
.DESCRIPTION
Have you ever used the Sensitivity button in a Microsoft 365 App or applied a sensitivity label by right-clicking on a file? If so, you've either used the Office's built-in labeling experience or the Purview Information Protection labeling client. If something is not working as expected with your DLP policies, sensitivity labels or you don't see any labels at all the 'Compliance Utility' will help you.
INTERNET ACCESS
The 'Compliance Utility' uses additional sources from the Internet to make its functionality fully available.
WARNING: Unexpected errors may occur, and some features may be limited, if there is no connection to the Internet.
.NOTES
MIT LICENSE
Copyright (c) Microsoft Corporation.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
VERSION
3.2.1
CREATE DATE
06/28/2024
AUTHOR
Claus Schiroky
Customer Service & Support | EMEA Modern Work Team
Microsoft Deutschland GmbH
GITHUB REPOSITORY
https://aka.ms/ComplianceUtility
PRIVACY STATEMENT
https://privacy.microsoft.com/PrivacyStatement
COPYRIGHT
Copyright (c) Microsoft Corporation.
.PARAMETER Information
This shows syntax, description and version information.
.PARAMETER License
This displays the MIT License.
.PARAMETER Help
This opens the online manual.
.PARAMETER Reset
IMPORTANT: Before you proceed with this option, please close all open applications.
This option removes all relevant policies, labels and settings.
Valid arguments are: "Default", or "Silent".
On Microsoft Windows:
Note:
- Reset with the default argument will not reset all settings, but only user-specific settings if you run PowerShell with user privileges. This is sufficient in most cases to reset Microsoft 365 Apps, while a complete reset is useful for all other applications.
- If you want a complete reset, you need to run the 'Compliance Utility' in an administrative PowerShell window as a user with local administrative privileges.
Default:
When you run PowerShell with user privileges, this argument removes all relevant policies, labels and settings:
ComplianceUtility -Reset Default
With the above command the following registry keys are cleaned up:
[HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\MSIPC]
[HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\AIPMigration]
[HKCU:\SOFTWARE\Classes\Microsoft.IPViewerChildMenu]
[HKCU:\SOFTWARE\Microsoft\Cloud\Office]
[HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\DRM]
[HKCU:\SOFTWARE\Wow6432Node\Microsoft\Office\16.0\Common\DRM]
[HKCU:\SOFTWARE\Policies\Microsoft\Office\16.0\Common\DRM]
[HKCU:\SOFTWARE\Microsoft\XPSViewer\Common\DRM]
[HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Identity]
[HKCU:\SOFTWARE\Microsoft\MSIP]
[HKCU:\SOFTWARE\Microsoft\MSOIdentityCRL]
[HKCR:\AllFilesystemObjects\shell\Microsoft.Azip.Inspect]
[HKCR:\AllFilesystemObjects\shell\Microsoft.Azip.RightClick]
The DRMEncryptProperty and OpenXMLEncryptProperty registry settings are purged of the following keys:
[HKCU:\SOFTWARE\Policies\Microsoft\Cloud\Office\16.0\Common\Security]
[HKCU:\SOFTWARE\Policies\Microsoft\Office\16.0\Common\Security]
[HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Security]
The UseOfficeForLabelling (Use the Sensitivity feature in Office to apply and view sensitivity labels) and AIPException (Use the Azure Information Protection add-in for sensitivity labeling) registry setting is purged of the following keys:
[HKCU:\SOFTWARE\Policies\Microsoft\Cloud\Office\16.0\Common\Security\Labels]
[HKCU:\SOFTWARE\Policies\Microsoft\Office\16.0\Common\Security\Labels]
[HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Security\Labels]
The following file system folders are cleaned up as well:
%LOCALAPPDATA%\Microsoft\Word\MIPSDK\mip
%LOCALAPPDATA%\Microsoft\Excel\MIPSDK\mip
%LOCALAPPDATA%\Microsoft\PowerPoint\MIPSDK\mip
%LOCALAPPDATA%\Microsoft\Outlook\MIPSDK\mip
%LOCALAPPDATA%\Microsoft\Office\DLP\mip
%LOCALAPPDATA%\Microsoft\Office\CLP
%TEMP%\Diagnostics
%LOCALAPPDATA%\Microsoft\MSIP
%LOCALAPPDATA%\Microsoft\MSIPC
%LOCALAPPDATA%\Microsoft\DRM
The Clear-AIPAuthentication cmdlet is used to reset user settings, if a Purview Information Protection labeling client (or an 'Azure Information Protection unified labeling client') installation is found.
When you run the 'Compliance Utility' in an administrative PowerShell window as a user with local administrative privileges, the following registry keys are cleaned up in addition:
[HKLM:\SOFTWARE\Wow6432Node\Microsoft\MSIPC]
[HKLM:\SOFTWARE\Microsoft\MSIPC]
[HKLM:\SOFTWARE\Microsoft\MSDRM]
[HKLM:\SOFTWARE\Wow6432Node\Microsoft\MSDRM]
[HKLM:\SOFTWARE\WOW6432Node\Microsoft\MSIP]
Silent:
This command line parameter argument does the same as "-Reset Default", but does not print any output - unless an error occurs when attempting to reset:
ComplianceUtility -Reset Silent
If a silent reset triggers an error, you can use the additional parameter "-Verbose" to find out more about the cause of the error:
ComplianceUtility -Reset Silent -Verbose
You can also review the Script.log file for errors of silent reset.
On Apple macOS:
The following file folders will be cleaned with Default argument:
~/Library/Containers/com.microsoft.Word/Data/Library/Application Support/Microsoft/Office/CLP
~/Library/Containers/com.microsoft.Excel/Data/Library/Application Support/Microsoft/Office/CLP
~/Library/Containers/com.microsoft.PowerPoint/Data/Library/Application Support/Microsoft/Office/CLP
~/Library/Containers/com.microsoft.Outlook/Data/Library/Application Support/Microsoft/Office/CLP
~/Library/Containers/com.microsoft.Word/Data/Library/Logs
~/Library/Containers/com.microsoft.Excel/Data/Library/Logs
~/Library/Containers/com.microsoft.PowerPoint/Data/Library/Logs
~/Library/Containers/com.microsoft.Outlook/Data/Library/Logs
~/Library/Containers/com.microsoft.protection.rms-sharing-mac/Data/Library/Logs
~/Library/Group Containers/UBF8T346G9.Office/mip_policy/mip/logs
Silent:
This command line parameter argument does the same as "-Reset Default", but does not print any output - unless an error occurs when attempting to reset:
ComplianceUtility -Reset Silent
If a silent reset triggers an error, you can use the additional parameter "-Verbose" to find out more about the cause of the error:
ComplianceUtility -Reset Silent -Verbose
You can also review the Script.log file for errors of silent reset.
.PARAMETER RecordProblem
IMPORTANT: Before you proceed with this option, please close all open applications.
As a first step, this parameter activates the required logging and then prompts you to reproduce the problem. While you’re doing so, the 'Compliance Utility' collects and records data. Once you have reproduced the problem, all collected files will be stored into the default logs folder (on Windows: '%temp%\ComplianceUtility', on macOS: '~/Documents/ComplianceUtility'). Every time you call this option, a new unique subfolder will be created in the logs-folder that reflects the date and time when it was created.
In the event that you accidentally close the PowerShell window while logging is enabled, the 'Compliance Utility' disables logging the next time you start it.
Note (for Windows user):
- Neither CAPI2 or AIP event logs, network trace nor filter drivers are recorded if the 'Compliance Utility' is not run in an administrative PowerShell window as a user with local administrative privileges.
Note (for Apple macOS user):
- When collecting basic system information, the message "'Terminal' wants to access data from other applications" may appear. Since no personal information is collected, only hardware and software data, it has no effect on how you confirm the message.
.PARAMETER CollectAIPServiceConfiguration
This parameter collects your AIP service configuration information (e.g. SuperUsers or OnboardingControlPolicy, etc.) by using the AIPService module.
The results are written to the log file AIPServiceConfiguration.log in the subfolder "Collect" of the Logs folder.
Note (for Windows user):
- You must run the 'Compliance Utility' in an administrative PowerShell window as a user with local administrative privileges to continue with this option. Please contact your administrator if necessary.
- You need to know your Microsoft 365 global administrator account information to proceed, as you will be asked for your credentials.
- The AIPService module does not yet support PowerShell 7.x. Therefore, unexpected errors may occur because the AIPService module is executed in compatibility mode in PowerShell 7.x.
Note (for Apple macOS user):
- This parameter is not available. It would require the AIPService module, which is not yet supported on PowerShell 7.x.
.PARAMETER CollectProtectionTemplates
This parameter collects protection templates of your tenant by using the AIPService module.
The results are written to the log files ProtectionTemplates.xml and ProtectionTemplateDetails.xml in the subfolder "Collect\ProtectionTemplates" of the Logs folder, and an export of each protection template (.xml) into the subfolder "ProtectionTemplatesBackup".
TIP: You can use this feature to create a backup copy of your protection templates.
Note (for Windows user):
- You must run the 'Compliance Utility' in an administrative PowerShell window as a user with local administrative privileges to continue with this option. Please contact your administrator if necessary.
- You need to know your Microsoft 365 global administrator account information to proceed, as you will be asked for your credentials.
- The AIPService module does not yet support PowerShell 7.x. Therefore, unexpected errors may occur because the AIPService module is executed in compatibility mode in PowerShell 7.x.
Note (for Apple macOS user):
- This parameter is not available. It would require the AIPService module, which is not yet supported on PowerShell 7.x.
.PARAMETER CollectEndpointURLs
This parameter collects important endpoint URLs. The URLs are taken from your local registry or your tenant's AIP service configuration information (by using the AIPService module), and extended by additional relevant URLs.
In a first step, this parameter is used to check whether you can access the URL. In a second step, the issuer of the corresponding certificate of the URL is collected. This process is represented by an output with the Tenant Id, Endpoint name, URL, and Issuer of the certificate. For example:
--------------------------------------------------
Tenant Id: 48fc04bd-c84b-44ac-b7991b7-a4c5eefd5ac1
--------------------------------------------------
Endpoint: UnifiedLabelingDistributionPointUrl
URL: https://dataservice.protection.outlook.com
Issuer: CN=DigiCert Cloud Services CA-1, O=DigiCert Inc, C=US
In addition, results are written into log file EndpointURLs.log in the subfolder "Collect" of the Logs folder.
Note (for Windows user):
- You must run the 'Compliance Utility' in an administrative PowerShell window as a user with local administrative privileges to continue with this option, if the corresponding Microsoft 365 App is not bootstraped. Please contact your administrator if necessary.
- You need to know your Microsoft 365 global administrator account information to proceed, as you will be asked for your credentials.
- The AIPService module does not yet support PowerShell 7.x. Therefore, unexpected errors may occur because the AIPService module is executed in compatibility mode in PowerShell 7.x.
Note (for Apple macOS user):
- This parameter is not available. It would require the AIPService module, which is not yet supported on PowerShell 7.x.
.PARAMETER CollectLabelsAndPolicies
This parameter collects Information Protection labels, policies (with detailled actions and rules), auto-label policies and rules from your Microsoft Purview compliance portal by using the Exchange Online PowerShell module.
The results are written to the log files Labels.xml, LabelsDetailedActions.xml, LabelPolicies.xml, LabelRules.xml, AutoLabelPolicies.xml and AutoLabelRules.xml in the subfolder "Collect\LabelsAndPolicies" of the Logs folder, and on Windows you can also have a CLP subfolder with the Office CLP policy.
TIP: You can use the resulting log file to create exact copies of the label and policy settings for troubleshooting purposes, e.g. in test environments.
Note:
- You must run the 'Compliance Utility' in an administrative PowerShell window as a user with local administrative privileges to continue with this option. Please contact your administrator if necessary.
- You need to know your Microsoft 365 global administrator account information to proceed with this option, as you will be asked for your credentials.
- The Microsoft Exchange Online Management module is required to proceed this option. If you do not have this module installed, 'Compliance Utility' will try to install it from PowerShell Gallery.
.PARAMETER CollectDLPRulesAndPolicies
This parameter collects DLP rules and policies, sensitive information type details, rule packages, keyword dictionaries and exact data match schemas from the Microsoft Purview compliance portal by using the Exchange Online PowerShell module.
The results are written to the log files DlpPolicy.xml, DlpRule.xml, DlpPolicyDistributionStatus.xml, DlpSensitiveInformationType.xml, DlpSensitiveInformationTypeRulePackage.xml, DlpKeywordDictionary.xml and DlpEdmSchema.xml in the subfolder "Collect\DLPRulesAndPolicies" of the Logs folder.
Note:
- You must run the 'Compliance Utility' in an administrative PowerShell window as a user with local administrative privileges to continue with this option. Please contact your administrator if necessary.
- You need to know your Microsoft 365 global administrator account information to proceed with this option, as you will be asked for your credentials.
- The Microsoft Exchange Online Management module is required to proceed this option. If you do not have this module installed, 'Compliance Utility' will try to install it from PowerShell Gallery.
.PARAMETER CollectUserLicenseDetails
This parameter collects the user license details by the Graph PowerShell module.
The results are written to the log file UserLicenseDetails.log in the subfolder "Collect" of the Logs folder.
Note:
- You must log in with the corresponding Microsoft 365 user account for which you want to check the license details.
- The Microsoft Graph PowerShell modules are required to proceed this option. If you do not have this module installed, 'Compliance Utility' will try to install it from PowerShell Gallery.
.PARAMETER CompressLogs
This command line parameter should always be used at the very end of a scenario.
This parameter compresses all collected log files and folders into a .zip archive, and the corresponding file is saved to your desktop. In addition, the default logs folder (on Windows: '%temp%\ComplianceUtility', on macOS: '~/Documents/ComplianceUtility') is cleaned.
.PARAMETER Menu
This will start the 'Compliance Utility' with the default menu.
.PARAMETER SkipUpdates
IMPORTANT: Use this parameter only if you are sure that all PowerShell modules are up to date.
This parameter skips the update check mechanism for all entries of the COLLECT menu.
.EXAMPLE
ComplianceUtility -Information
This shows syntax and description.
.EXAMPLE
ComplianceUtility -License
This displays the MIT License.
.EXAMPLE
ComplianceUtility -Help
This parameter opens the online manual.
.EXAMPLE
ComplianceUtility -Reset Default
This parameter removes all relevant policies, labels and settings.
.EXAMPLE
ComplianceUtility -Reset Silent
This parameter removes all relevant policies, labels and settings without any output.
.EXAMPLE
ComplianceUtility -RecordProblem
This parameter cleans up existing MSIP/MSIPC log folders, then it removes all relevant policies, labels and settings, and starts recording data.
.EXAMPLE
ComplianceUtility -CollectAIPServiceConfiguration
This parameter collects AIP service configuration information of your tenant.
.EXAMPLE
ComplianceUtility -CollectProtectionTemplates
This parameter collects protection templates of your tenant.
.EXAMPLE
ComplianceUtility -CollectLabelsAndPolicies
This parameter collects the labels and policy definitions from the Microsoft Purview compliance portal.
.EXAMPLE
ComplianceUtility -CollectEndpointURLs
This parameter collects important enpoint URLs.
.EXAMPLE
ComplianceUtility -CollectDLPRulesAndPolicies
This parameter collects DLP rules and policies from the Microsoft Purview compliance portal.
.EXAMPLE
ComplianceUtility -CollectUserLicenseDetails
This parameter collects the user license details by Microsoft Graph.
.EXAMPLE
ComplianceUtility -CompressLogs
This parameter compress all collected logs files into a .zip archive, and the corresponding path and file name is displayed.
.EXAMPLE
ComplianceUtility -Reset Default -RecordProblem -CompressLogs
This parameter removes all relevant policies, labels and settings, starts recording data, and compress all collected logs files to a .zip archive on the desktop.
.EXAMPLE
ComplianceUtility -Menu
This will start the 'Compliance Utility' with the default menu.
.LINK
https://aka.ms/ComplianceUtility
#>
<# Binding for parameters #>
[CmdletBinding (
HelpURI = "https://github.com/microsoft/ComplianceUtility/blob/main/Manuals/3.2.1/Manual-Win.md", <# URL for online manual #>
PositionalBinding = $false, <# None-positional parameters #>
DefaultParameterSetName = "Menu" <# Default start parameter #>
)]
[Alias("CompUtil","UnifiedLabelingSupportTool")]
<# Parameter definitions #>
Param (
<# Information #>
[Alias("i")]
[Parameter(ParameterSetName = "Information")]
[switch]$Information,
<# License #>
[Alias("m")]
[Parameter(ParameterSetName = "License")]
[switch]$License,
<# Help #>
[Alias("h")]
[Parameter(ParameterSetName = "Help")]
[switch]$Help,
<# Reset #>
[Alias("r")]
[Parameter(ParameterSetName = "Reset and logging")]
[ValidateSet("Default", "Silent")]
[string]$Reset="Default",
<# RecordProblem #>
[Alias("p")]
[parameter(ParameterSetName = "Reset and logging")]
[switch]$RecordProblem,
<# CollectAIPServiceConfiguration #>
[Alias("a")]
[Parameter(ParameterSetName = "Reset and logging")]
[switch]$CollectAIPServiceConfiguration,
<# CollectProtectionTemplates #>
[Alias("t")]
[Parameter(ParameterSetName = "Reset and logging")]
[switch]$CollectProtectionTemplates,
<# CollectEndpointURLs #>
[Alias("e")]
[Parameter(ParameterSetName = "Reset and logging")]
[switch]$CollectEndpointURLs,
<# CollectLabelsAndPolicies #>
[Alias("l")]
[Parameter(ParameterSetName = "Reset and logging")]
[switch]$CollectLabelsAndPolicies,
<# CollectDLPPoliciesAndRules #>
[Alias("d")]
[Parameter(ParameterSetName = "Reset and logging")]
[switch]$CollectDLPRulesAndPolicies,
<# CollectUserLicenseDetails #>
[Alias("u")]
[Parameter(ParameterSetName = "Reset and logging")]
[switch]$CollectUserLicenseDetails,
<# SkipUPdates #>
[Parameter(ParameterSetName = "Menu")]
[Parameter(ParameterSetName = "Reset and logging")]
[switch]$SkipUpdates,
<# CompressLogs #>
[Alias("z")]
[Parameter(ParameterSetName = "Reset and logging")]
[switch]$CompressLogs,
<# Menu #>
[Parameter(ParameterSetName = "Menu")]
[switch]$Menu
)
<# Actions for Information #>
If ($PsCmdlet.ParameterSetName -eq "Information") {
<# Call Information #>
fncInformation
<# Logging #>
fncLogging -strLogFunction "ComplianceUtility" -strLogDescription "INFORMATION" -strLogValue "Proceeded"
}
<# Actions for License #>
If ($PSBoundParameters.ContainsKey("License")) {
<# Call License #>
fncLicense
<# Logging #>
fncLogging -strLogFunction "ComplianceUtility" -strLogDescription "LICENSE" -strLogValue "Proceeded"
}
<# Actions for Help #>
If ($PSBoundParameters.ContainsKey("Help")) {
<# Call Help #>
fncHelp
<# Logging #>
fncLogging -strLogFunction "ComplianceUtility" -strLogDescription "HELP" -strLogValue "Proceeded"
}
<# Actions for Reset #>
If ($PSBoundParameters.ContainsKey("Reset")) {
<# Logging #>
fncLogging -strLogFunction "ComplianceUtility" -strLogDescription "Parameter Help" -strLogValue "Triggered"
<# Call Reset #>
fncReset -strResetMethod $Reset
}
<# Actions for RecordProblem #>
If ($PSBoundParameters.ContainsKey("RecordProblem")) {
<# Logging #>
fncLogging -strLogFunction "ComplianceUtility" -strLogDescription "Parameter RecordProblem" -strLogValue "Triggered"
<# Call RecordProblem #>
fncRecordProblem
}
<# Variable for unavailable COLLECT features on macOS #>
$Private:strNotAvailableOnMac = "This feature is not yet available on Apple macOS."
<# Actions for SkipUpdates #>
If ($PSBoundParameters.ContainsKey("SkipUpdates")) {
<# Logging #>
fncLogging -strLogFunction "ComplianceUtility" -strLogDescription "Parameter SkipUpdates" -strLogValue "Triggered"
<# Define variable #>
$Global:bolSkipRequiredUpdates | Out-Null
<# Disabling updates check #>
$Global:bolSkipRequiredUpdates = $true
}
<# Actions CollectAIPServiceConfiguration #>
If ($PSBoundParameters.ContainsKey("CollectAIPServiceConfiguration")) {
<# Logging #>
fncLogging -strLogFunction "ComplianceUtility" -strLogDescription "Parameter CollectAIPServiceConfiguration" -strLogValue "Triggered"
<# Consider Windows #>
If ([System.Environment]::OSVersion.Platform -eq "Win32NT") {
<# Call CollectAIPServiceConfiguration #>
fncCollectAIPServiceConfiguration
}
Else {
<# Message on macOS #>
Write-Output $Private:strNotAvailableOnMac
}
}
<# Actions for CollectProtectionTemplates #>
If ($PSBoundParameters.ContainsKey("CollectProtectionTemplates")) {
<# Logging #>
fncLogging -strLogFunction "ComplianceUtility" -strLogDescription "Parameter CollectProtectionTemplates" -strLogValue "Triggered"
<# Consider Windows #>
If ([System.Environment]::OSVersion.Platform -eq "Win32NT") {
<# Call CollectProtectionTemplates #>
fncCollectProtectionTemplates
}
Else {
<# Message on macOS #>
Write-Output $Private:strNotAvailableOnMac
}
}
<# Actions for CollectUserLicenseDetails #>
If ($PSBoundParameters.ContainsKey("CollectUserLicenseDetails")) {
<# Logging #>
fncLogging -strLogFunction "ComplianceUtility" -strLogDescription "Parameter CollectUserLicenseDetails" -strLogValue "Triggered"
<# Call CollectUserLicenseDetails #>
fncCollectUserLiceneseDetails
}
<# Actions for CollectLabelsAndPolicies #>
If ($PSBoundParameters.ContainsKey("CollectLabelsAndPolicies")) {
<# Logging #>
fncLogging -strLogFunction "ComplianceUtility" -strLogDescription "Parameter CollectLabelsAndPolicies" -strLogValue "Triggered"
<# Call CollectLabelsAndPolicies #>
fncCollectLabelsAndPolicies
}
<# Actions for CollectEndpointURLs #>
If ($PSBoundParameters.ContainsKey("CollectEndpointURLs")) {
<# Logging #>
fncLogging -strLogFunction "ComplianceUtility" -strLogDescription "Parameter CollectEndpointsURLs" -strLogValue "Triggered"
<# Consider Windows #>
If ([System.Environment]::OSVersion.Platform -eq "Win32NT") {
<# Call CollectEndpointURLs #>
fncCollectEndpointURLs
}
Else {
<# Message on macOS #>
Write-Output $Private:strNotAvailableOnMac
}
}
<# Actions for CollectDLPRulesAndPolicies #>
If ($PSBoundParameters.ContainsKey("CollectDLPRulesAndPolicies")) {
<# Logging #>
fncLogging -strLogFunction "ComplianceUtility" -strLogDescription "Parameter CollectDLPRulesAndPolicies" -strLogValue "Triggered"
<# Call CollectDLPRulesAndPolicies #>
fncCollectDLPRulesAndPolicies
}
<# Actions for CompressLogs #>
If ($PSBoundParameters.ContainsKey("CompressLogs")) {
<# Logging #>
fncLogging -strLogFunction "ComplianceUtility" -strLogDescription "Parameter CompressLogs" -strLogValue "Triggered"
<# Call CompressLogs #>
fncCompressLogs
<# Set back window title to default #>
$Global:host.UI.RawUI.WindowTitle = $Global:strDefaultWindowTitle
<# Exit #>
Break
}
<# Actions for ShowMenu #>
If ($PsCmdlet.ParameterSetName -eq "Menu") {
<# Logging #>
fncLogging -strLogFunction "ComplianceUtility" -strLogDescription "MENU" -strLogValue "Triggered"
<# Call ShowMenu #>
fncShowMenu
}
}
Function fncLogging ($strLogFunction, $strLogDescription, $strLogValue) {
<# Detect/create UserLogPath #>
If ($(Test-Path -Path $Global:strUserLogPath) -Eq $false) {
New-Item -ItemType Directory -Force -Path $Global:strUserLogPath | Out-Null <# Define UserLogPath #>
}
<# Output #>
Write-Verbose "$(Get-Date -UFormat "%Y-%m-%d"), $(Get-Date -UFormat "%H:%M"), $strLogFunction, $strLogDescription, $strLogValue"
<# Append output #>
Write-Verbose "$(Get-Date -UFormat "%Y-%m-%d"), $(Get-Date -UFormat "%H:%M"), $strLogFunction, $strLogDescription, $strLogValue" -ErrorAction SilentlyContinue -Verbose 4>> "$Global:strUserLogPath\Script.log"
}
Function fncInformation {
<# Logging #>
fncLogging -strLogFunction "fncInformation" -strLogDescription "INFORMATION" -strLogValue "Called"
<# Command line actions #>
If ($Global:bolCommingFromMenu -eq $false) {
<# Call Information #>
Get-Help -Verbose:$false ComplianceUtility
}
<# Menu Actions #>
If ($Global:bolCommingFromMenu -eq $true) {
<# Output #>
Write-Output "NAME:`nComplianceUtility`n`nDESCRIPTION:`nThe 'Compliance Utility' is a powerful tool that helps troubleshoot and diagnose sensitivity labels, policies, settings and more. Whether you need to fix issues or reset configurations, this tool has you covered.`n`nVERSION:`n$Global:strVersion`n`nAUTHOR:`nClaus Schiroky`nCustomer Service & Support - EMEA Modern Work Team`nMicrosoft Deutschland GmbH`n`nHOMEPAGE:`nhttps://aka.ms/ComplianceUtility`n`nPRIVACY STATEMENT:`nhttps://privacy.microsoft.com/PrivacyStatement`n`nCOPYRIGHT:`nCopyright (c) Microsoft Corporation.`n"
}
}
Function fncLicense {
<# Logging #>
fncLogging -strLogFunction "fncLicense" -strLogDescription "LICENSE" -strLogValue "Called"
<# Output #>
Write-Output "MIT License`n`nCopyright (c) Microsoft Corporation.`n`nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the `"Software`"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:`n`nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.`n`nTHE SOFTWARE IS PROVIDED `"AS IS`", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.`n"
}
Function fncHelp {
<# No internet message #>
$Private:strNoOnlineHelp = "ATTENTION: The online manual cannot be accessed.`nEither the website (github.com) is unavailable or there is no internet connection.`n`nNote:`n`n- Please use the command line help by entering the command:`nGet-Help ComplianceUtility -Detailed"
<# Open manual on Windows #>
If ([System.Environment]::OSVersion.Platform -eq "Win32NT") {
<# Check internet connection #>
If ($(fncTestInternetAccess "github.com") -Eq $true) {
<# Open manual #>
Start-Process "https://github.com/microsoft/ComplianceUtility/blob/main/Manuals/3.2.1/Manual-Win.md"
<# Logging #>
fncLogging -strLogFunction "fncHelp" -strLogDescription "HELP" -strLogValue "Called"
}
Else { <# Offline actions #>
<# Output #>
Write-ColoredOutput Red $Private:strNoOnlineHelp
<# Logging #>
fncLogging -strLogFunction "fncHelp" -strLogDescription "Help" -strLogValue "No internet connection"
}
}
<# Open mnanual on macOS #>
If ($IsMacOS -eq $true) {
<# Check internet connection #>
If ($(fncTestInternetAccess "github.com") -Eq $true) {
<# Open manual #>
Open "https://github.com/microsoft/ComplianceUtility/blob/main/Manuals/3.2.1/Manual-Mac.md"
<# Logging #>
fncLogging -strLogFunction "fncHelp" -strLogDescription "HELP" -strLogValue "Called"
}
Else { <# Offline action #>
<# Output #>
Write-ColoredOutput Red $Private:strNoOnlineHelp
<# Logging #>
fncLogging -strLogFunction "fncHelp" -strLogDescription "Help" -strLogValue "No internet connection"
}
}
}
Function Write-ColoredOutput($Private:ForegroundColor) {
<# Variables #>
$Private:TextColor = $Global:host.UI.RawUI.ForegroundColor <# Backup current text color #>
$Global:host.UI.RawUI.ForegroundColor = $Private:ForegroundColor <# Set text color #>
<# Output #>
If ($Private:args) {
Write-Output $Private:args
}
Else {
$Private:input | Write-Output
}
<# Set back color #>
$Global:host.UI.RawUI.ForegroundColor = $Private:TextColor
}
<# Detect and delete a registry setting #>
Function fncDeleteRegistrySetting ($strRegistryKey, $strRegistrySetting) {
<# Try to remove registry setting #>
Try {
<# Set registry setting variable #>
$strItemExists = Get-ItemProperty $strRegistryKey $strRegistrySetting -ErrorAction SilentlyContinue
<# Remove registry setting only if it exists #>
If (-not ($Null -eq $strItemExists) -or ($strItemExists.Length -eq 0)) {
<# Remove registry setting #>
Remove-ItemProperty -Path $strRegistryKey -Name $strRegistrySetting -Force -ErrorAction Stop
<# Logging #>
fncLogging -strLogFunction "fncDeleteRegistrySetting" -strLogDescription "$strRegistrySetting ($strRegistryKey)" -strLogValue "Removed"
}
}
Catch {
<# Silently ignore if setting does not exist #>
}
}
Function fncReset ($strResetMethod) {
<# ShowMenu/Silent actions #>
If ($strResetMethod -notmatch "Silent") {
<# Output #>
Write-Output "RESET:"
Write-ColoredOutput Red "IMPORTANT: Before you proceed with this option, please close all open applications."
$Private:ReadHost = Read-Host "Only if the above is true, please press [Y]es to continue, or [N]o to cancel"
<# Cancel/no actions #>
If ($Private:ReadHost -eq "N") {
<# Logging #>
fncLogging -strLogFunction "fncReset" -strLogDescription "RESET Default" -strLogValue "Canceled"
<# Command line actions #>
If ($Global:bolCommingFromMenu -eq $false) {
<# Set back window title #>
$Global:host.UI.RawUI.WindowTitle = $Global:strDefaultWindowTitle
<# Exit #>
Break
}
<# ShowMenu actions #>
If ($Global:bolCommingFromMenu -eq $true) {
<# Clear console #>
Clear-Host
<# Call ShowMenu #>
fncShowMenu
}
}
<# Logging #>
fncLogging -strLogFunction "fncReset" -strLogDescription "RESET Default" -strLogValue "Initiated"
<# Output #>
Write-Output "Resetting..."
}
<# Silent actions #>
If ($strResetMethod -match "Silent") {
<# Logging #>
fncLogging -strLogFunction "fncReset" -strLogDescription "RESET Silent" -strLogValue "Initiated"
}