-
Notifications
You must be signed in to change notification settings - Fork 33
/
ASDOffice2016HardeningComplianceCheck.ps1
2581 lines (2161 loc) · 103 KB
/
ASDOffice2016HardeningComplianceCheck.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
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
#Authors: David Cottingham & Huda Minhaj
#Purpose: This script checks for compliance with the ASD Office 2016 hardening guide by checking registry keys on the local machine. Where checks are unable to be performed in this manner, either other methods of scanning are used or the user is prompted for manual checking.
#This script is designed to be used as a simple spot check of a endpoint to ensure the correct settings are applied, regardless of how complex an organisations group policy may be.
#The ASD hardening guide for Office 2016 can be downloaded here: https://www.asd.gov.au/publications/protect/Hardening_MS_Office_2016.pdf
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[string[]]$ComputerName = $env:COMPUTERNAME,
[switch]$ShowAllInstalledProducts,
[System.Management.Automation.PSCredential]$Credentials
)
Function Get-OfficeVersion {
[CmdletBinding(SupportsShouldProcess=$true)]
param(
[Parameter(ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true, Position=0)]
[string[]]$ComputerName = $env:COMPUTERNAME,
[switch]$ShowAllInstalledProducts,
[System.Management.Automation.PSCredential]$Credentials
)
begin {
$HKLM = [UInt32] "0x80000002"
$HKCR = [UInt32] "0x80000000"
$excelKeyPath = "Excel\DefaultIcon"
$wordKeyPath = "Word\DefaultIcon"
$installKeys = 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall',
'SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall'
$officeKeys = 'SOFTWARE\Microsoft\Office',
'SOFTWARE\Wow6432Node\Microsoft\Office'
$defaultDisplaySet = 'DisplayName','Version', 'ComputerName'
$defaultDisplayPropertySet = New-Object System.Management.Automation.PSPropertySet('DefaultDisplayPropertySet',[string[]]$defaultDisplaySet)
$PSStandardMembers = [System.Management.Automation.PSMemberInfo[]]@($defaultDisplayPropertySet)
}
process {
$results = new-object PSObject[] 0;
$MSexceptionList = "mui","visio","project","proofing","visual"
foreach ($computer in $ComputerName) {
if ($Credentials) {
$os=Get-WMIObject win32_operatingsystem -computername $computer -Credential $Credentials
} else {
$os=Get-WMIObject win32_operatingsystem -computername $computer
}
$osArchitecture = $os.OSArchitecture
if ($Credentials) {
$regProv = Get-Wmiobject -list "StdRegProv" -namespace root\default -computername $computer -Credential $Credentials
} else {
$regProv = Get-Wmiobject -list "StdRegProv" -namespace root\default -computername $computer
}
[System.Collections.ArrayList]$VersionList = New-Object -TypeName System.Collections.ArrayList
[System.Collections.ArrayList]$PathList = New-Object -TypeName System.Collections.ArrayList
[System.Collections.ArrayList]$PackageList = New-Object -TypeName System.Collections.ArrayList
[System.Collections.ArrayList]$ClickToRunPathList = New-Object -TypeName System.Collections.ArrayList
[System.Collections.ArrayList]$ConfigItemList = New-Object -TypeName System.Collections.ArrayList
$ClickToRunList = new-object PSObject[] 0;
foreach ($regKey in $officeKeys) {
$officeVersion = $regProv.EnumKey($HKLM, $regKey)
foreach ($key in $officeVersion.sNames) {
if ($key -match "\d{2}\.\d") {
if (!$VersionList.Contains($key)) {
$AddItem = $VersionList.Add($key)
}
$path = join-path $regKey $key
$configPath = join-path $path "Common\Config"
$configItems = $regProv.EnumKey($HKLM, $configPath)
if ($configItems) {
foreach ($configId in $configItems.sNames) {
if ($configId) {
$Add = $ConfigItemList.Add($configId.ToUpper())
}
}
}
$cltr = New-Object -TypeName PSObject
$cltr | Add-Member -MemberType NoteProperty -Name InstallPath -Value ""
$cltr | Add-Member -MemberType NoteProperty -Name UpdatesEnabled -Value $false
$cltr | Add-Member -MemberType NoteProperty -Name UpdateUrl -Value ""
$cltr | Add-Member -MemberType NoteProperty -Name StreamingFinished -Value $false
$cltr | Add-Member -MemberType NoteProperty -Name Platform -Value ""
$cltr | Add-Member -MemberType NoteProperty -Name ClientCulture -Value ""
$packagePath = join-path $path "Common\InstalledPackages"
$clickToRunPath = join-path $path "ClickToRun\Configuration"
$virtualInstallPath = $regProv.GetStringValue($HKLM, $clickToRunPath, "InstallationPath").sValue
[string]$officeLangResourcePath = join-path $path "Common\LanguageResources"
$mainLangId = $regProv.GetDWORDValue($HKLM, $officeLangResourcePath, "SKULanguage").uValue
if ($mainLangId) {
$mainlangCulture = [globalization.cultureinfo]::GetCultures("allCultures") | where {$_.LCID -eq $mainLangId}
if ($mainlangCulture) {
$cltr.ClientCulture = $mainlangCulture.Name
}
}
[string]$officeLangPath = join-path $path "Common\LanguageResources\InstalledUIs"
$langValues = $regProv.EnumValues($HKLM, $officeLangPath);
if ($langValues) {
foreach ($langValue in $langValues) {
$langCulture = [globalization.cultureinfo]::GetCultures("allCultures") | where {$_.LCID -eq $langValue}
}
}
if ($virtualInstallPath) {
} else {
$clickToRunPath = join-path $regKey "ClickToRun\Configuration"
$virtualInstallPath = $regProv.GetStringValue($HKLM, $clickToRunPath, "InstallationPath").sValue
}
if ($virtualInstallPath) {
if (!$ClickToRunPathList.Contains($virtualInstallPath.ToUpper())) {
$AddItem = $ClickToRunPathList.Add($virtualInstallPath.ToUpper())
}
$cltr.InstallPath = $virtualInstallPath
$cltr.StreamingFinished = $regProv.GetStringValue($HKLM, $clickToRunPath, "StreamingFinished").sValue
$cltr.UpdatesEnabled = $regProv.GetStringValue($HKLM, $clickToRunPath, "UpdatesEnabled").sValue
$cltr.UpdateUrl = $regProv.GetStringValue($HKLM, $clickToRunPath, "UpdateUrl").sValue
$cltr.Platform = $regProv.GetStringValue($HKLM, $clickToRunPath, "Platform").sValue
$cltr.ClientCulture = $regProv.GetStringValue($HKLM, $clickToRunPath, "ClientCulture").sValue
$ClickToRunList += $cltr
}
$packageItems = $regProv.EnumKey($HKLM, $packagePath)
$officeItems = $regProv.EnumKey($HKLM, $path)
foreach ($itemKey in $officeItems.sNames) {
$itemPath = join-path $path $itemKey
$installRootPath = join-path $itemPath "InstallRoot"
$filePath = $regProv.GetStringValue($HKLM, $installRootPath, "Path").sValue
if (!$PathList.Contains($filePath)) {
$AddItem = $PathList.Add($filePath)
}
}
foreach ($packageGuid in $packageItems.sNames) {
$packageItemPath = join-path $packagePath $packageGuid
$packageName = $regProv.GetStringValue($HKLM, $packageItemPath, "").sValue
if (!$PackageList.Contains($packageName)) {
if ($packageName) {
$AddItem = $PackageList.Add($packageName.Replace(' ', '').ToLower())
}
}
}
}
}
}
foreach ($regKey in $installKeys) {
$keyList = new-object System.Collections.ArrayList
$keys = $regProv.EnumKey($HKLM, $regKey)
foreach ($key in $keys.sNames) {
$path = join-path $regKey $key
$installPath = $regProv.GetStringValue($HKLM, $path, "InstallLocation").sValue
if (!($installPath)) { continue }
if ($installPath.Length -eq 0) { continue }
$buildType = "64-Bit"
if ($osArchitecture -eq "32-bit") {
$buildType = "32-Bit"
}
if ($regKey.ToUpper().Contains("Wow6432Node".ToUpper())) {
$buildType = "32-Bit"
}
if ($key -match "{.{8}-.{4}-.{4}-1000-0000000FF1CE}") {
$buildType = "64-Bit"
}
if ($key -match "{.{8}-.{4}-.{4}-0000-0000000FF1CE}") {
$buildType = "32-Bit"
}
if ($modifyPath) {
if ($modifyPath.ToLower().Contains("platform=x86")) {
$buildType = "32-Bit"
}
if ($modifyPath.ToLower().Contains("platform=x64")) {
$buildType = "64-Bit"
}
}
$primaryOfficeProduct = $false
$officeProduct = $false
foreach ($officeInstallPath in $PathList) {
if ($officeInstallPath) {
try{
$installReg = "^" + $installPath.Replace('\', '\\')
$installReg = $installReg.Replace('(', '\(')
$installReg = $installReg.Replace(')', '\)')
if ($officeInstallPath -match $installReg) { $officeProduct = $true }
} catch {}
}
}
if (!$officeProduct) { continue };
$name = $regProv.GetStringValue($HKLM, $path, "DisplayName").sValue
$primaryOfficeProduct = $true
if ($ConfigItemList.Contains($key.ToUpper()) -and $name.ToUpper().Contains("MICROSOFT OFFICE")) {
foreach($exception in $MSexceptionList){
if($name.ToLower() -match $exception.ToLower()){
$primaryOfficeProduct = $false
}
}
} else {
$primaryOfficeProduct = $false
}
$clickToRunComponent = $regProv.GetDWORDValue($HKLM, $path, "ClickToRunComponent").uValue
$uninstallString = $regProv.GetStringValue($HKLM, $path, "UninstallString").sValue
if (!($clickToRunComponent)) {
if ($uninstallString) {
if ($uninstallString.Contains("OfficeClickToRun")) {
$clickToRunComponent = $true
}
}
}
$modifyPath = $regProv.GetStringValue($HKLM, $path, "ModifyPath").sValue
$version = $regProv.GetStringValue($HKLM, $path, "DisplayVersion").sValue
$cltrUpdatedEnabled = $NULL
$cltrUpdateUrl = $NULL
$clientCulture = $NULL;
[string]$clickToRun = $false
if ($clickToRunComponent) {
$clickToRun = $true
if ($name.ToUpper().Contains("MICROSOFT OFFICE")) {
$primaryOfficeProduct = $true
}
foreach ($cltr in $ClickToRunList) {
if ($cltr.InstallPath) {
if ($cltr.InstallPath.ToUpper() -eq $installPath.ToUpper()) {
$cltrUpdatedEnabled = $cltr.UpdatesEnabled
$cltrUpdateUrl = $cltr.UpdateUrl
if ($cltr.Platform -eq 'x64') {
$buildType = "64-Bit"
}
if ($cltr.Platform -eq 'x86') {
$buildType = "32-Bit"
}
$clientCulture = $cltr.ClientCulture
}
}
}
}
if (!$primaryOfficeProduct) {
if (!$ShowAllInstalledProducts) {
continue
}
}
$object = New-Object PSObject -Property @{DisplayName = $name; Version = $version; InstallPath = $installPath; ClickToRun = $clickToRun;
Bitness=$buildType; ComputerName=$computer; ClickToRunUpdatesEnabled=$cltrUpdatedEnabled; ClickToRunUpdateUrl=$cltrUpdateUrl;
ClientCulture=$clientCulture }
$object | Add-Member MemberSet PSStandardMembers $PSStandardMembers
$results += $object
}
}
}
$results = Get-Unique -InputObject $results
return $results;
}
}
$officetemp = Get-OfficeVersion | select -ExpandProperty version
$officeversion = $officetemp.Substring(0,4)
$officeuserhive = Get-ChildItem -Path "Registry::HKCU\Software\Policies\Microsoft\Office\$officeversion\" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name
$officelocalhive = Get-ChildItem -Path "Registry::HKLM\Software\Policies\Microsoft\Office\$officeversion\" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name
if ($officeuserhive -eq $null -and $officelocalhive -eq $null)
{
write-host "No Microsoft Office group policies were detected, this script will now exit" -ForegroundColor Yellow
pause
break
}
write-host "`r`n####################### ATTACK SURFACE REDUCTION #######################`r`n"
#This section could be improved to check sub settings for each exploitguard rule to ensure the configured rules are set to block
$ExploitGuard_ASR_Rules = Get-ItemProperty -Path "Registry::HKLM\Software\Policies\Microsoft\Windows Defender\Windows Defender Exploit Guard\ASR" -Name ExploitGuard_ASR_Rules -ErrorAction SilentlyContinue|Select-Object -ExpandProperty ExploitGuard_ASR_Rules
if ($ExploitGuard_ASR_Rules -eq $null)
{
write-host "Configure Attack Surface Reduction rules is not configured or disabled" -ForegroundColor Yellow
}
elseif ($ExploitGuard_ASR_Rules -eq '1')
{
write-host "Configure Attack Surface Reduction rules is Enabled" -ForegroundColor Green
Get-ChildItem -Path "Registry::HKLM\Software\Policies\Microsoft\Windows Defender\Windows Defender Exploit Guard\ASR\" | Select-Object -ExpandProperty Property | ForEach-Object{
if ($_ -contains "3b576869-a4ec-4529-8536-b80a7769e899")
{
write-host "Block Office applications from creating executable content is set" -ForegroundColor Green
$blockofficeapps = 1
}
if ($_ -contains "BE9BA2D9-53EA-4CDC-84E5-9B1EEEE46550")
{
write-host "Block executable content from email client and webmail is set" -ForegroundColor Green
$blockexecutablecontent = 1
}
if ($_ -contains "D4F940AB-401B-4EFC-AADC-AD5F3C50688A")
{
write-host "Block Office applications from creating child processes is set" -ForegroundColor Green
$blockofficechildprocess = 1
}
if ($_ -contains "75668C1F-73B5-4CF0-BB93-3ECF5CB7CC84")
{
write-host "Block Office applications from injecting code into other processes is set" -ForegroundColor Green
$blockcodeinjection = 1
}
if ($_ -contains "D3E037E1-3EB8-44C8-A917-57927947596D")
{
write-host "Block JavaScript and VBScript from launching downloaded executable content is set" -ForegroundColor Green
$blockjavavbscript = 1
}
if ($_ -contains "5BEB7EFE-FD9A-4556-801D-275E5FFC04CC")
{
write-host "Block execution of potentially obfuscated scripts is set" -ForegroundColor Green
$blockobfuscated = 1
}
if ($_ -contains "92E97FA1-2EDF-4476-BDD6-9DD0B4DDDC7B")
{
write-host "Block Win32 API calls from Office macro is set" -ForegroundColor Green
$blockwin32api = 1
}
}
if ($blockofficeapps -ne '1')
{
write-host "Block Office applications from creating executable content is not set" -ForegroundColor Red
}
if ($blockexecutablecontent -ne '1')
{
write-host "Block executable content from email client and webmail is not set" -ForegroundColor Red
}
if ($blockofficechildprocess -ne '1')
{
write-host "Block Office applications from creating child processes is not set" -ForegroundColor Red
}
if ($blockcodeinjection -ne '1')
{
write-host "Block Office applications from injecting code into other processes is not set" -ForegroundColor Red
}
if ($blockjavavbscript -ne '1')
{
write-host "Block JavaScript and VBScript from launching downloaded executable content is not set" -ForegroundColor Red
}
if ($blockobfuscated -ne '1')
{
write-host "Block execution of potentially obfuscated scripts is not set" -ForegroundColor Red
}
if ($blockwin32api -ne '1')
{
write-host "Block Win32 API calls from Office macro is not set" -ForegroundColor Red
}
}
else
{
write-host "Configure Attack Surface Reduction rules is configured with a setting of $_" -ForegroundColor Red
}
write-host "`r`n####################### MACROS #######################`r`n"
Get-ChildItem -Path "Registry::HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\$officeversion\" | Select-Object -ExpandProperty Name | ForEach-Object{
$officename = ($_).Split('\')[6]
if ($officename.Contains("outlook") -or $officename.Contains("common") -or $officename.Contains("firstrun") -or $officename.Contains("onenote") -or $officename.Contains("Registration"))
{
#donothing
}
else
{
$appsetting = Get-ItemProperty -Path Registry::$_\Security -ErrorAction SilentlyContinue| Select-Object -ExpandProperty VBAWarnings -ErrorAction SilentlyContinue
If ($appsetting -eq $null)
{
write-host "Macro settings have not been configured in $officename" -ForegroundColor Yellow
}
elseif ($appsetting -eq "4")
{
write-host "Macros are disabled in $officename" -ForegroundColor Green
}
elseif ($appsetting -eq "1")
{
Write-Host "Macros are not disabled in $officename, set to Enable all Macros ($appsetting)" -ForegroundColor Red
}
elseif ($appsetting -eq "2")
{
Write-Host "Macros are not disabled in $officename, Disable all Macros with notification ($appsetting)" -ForegroundColor Red
}
elseif ($appsetting -eq "3")
{
Write-Host "Macros are not disabled in $officename, Disable all Macros except those digitally signed ($appsetting)" -ForegroundColor Red
}
else
{
Write-Host "Macros are not disabled in $officename, value is unknown and set to $appsetting" -ForegroundColor Red
}
$apptoscan = $_
$tldisable = Get-ItemProperty -Path "Registry::$apptoscan\Security\Trusted Locations" -Name alllocationsdisabled -ErrorAction SilentlyContinue|Select-Object -ExpandProperty alllocationsdisabled
if ($tldisable -eq '1')
{
write-host "Trusted Locations for $officename are disabled" -ForegroundColor Green
}
else
{
write-host "Trusted Locations For $officename are enabled" -ForegroundColor Yellow
foreach($_ in 1..50)
{
$i++
$trustedlocation = Get-ItemProperty -Path "Registry::$apptoscan\Security\Trusted Locations\location$_" -Name path -ErrorAction SilentlyContinue|Select-Object -ExpandProperty path
If ($trustedlocation -ne $null)
{
write-host "$trustedlocation" -ForegroundColor Magenta
}
}
}
}
}
#Outlook has unique macro settings so we check them separately here
$macrooutlook = Get-ItemProperty -Path Registry::HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\$officeversion\outlook\Security -ErrorAction SilentlyContinue| Select-Object -ExpandProperty level -ErrorAction SilentlyContinue
If ($macrooutlook -eq $null)
{
write-host "Macro settings have not been configured in Microsoft Outlook" -ForegroundColor Yellow
}
elseif ($macrooutlook -eq "4"){
write-host "Macros are disabled in Microsoft Outlook" -ForegroundColor Green
}
elseif ($macrooutlook -eq"1")
{Write-Host "Macros are not disabled in Microsoft Outlook, set to Enable all Macros" -ForegroundColor Red}
elseif ($macrooutlook -eq"2")
{Write-Host "Macros are not disabled in Microsoft Outlook, set to Notifications for All Macros" -ForegroundColor Red}
elseif ($macrooutlook -eq"3")
{Write-Host "Macros are not disabled in Microsoft Outlook, set to Disable all Macros except those digitally signed" -ForegroundColor Red}
else {Write-host "Macros are not disabled in Microsoft Outlook, value is unknown and set to $macrooutlook" -ForegroundColor Red}
#MS Outlook
$tldisable = Get-ItemProperty -Path "Registry::HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\$officeversion\Security\Trusted Locations" -Name alllocationsdisabled -ErrorAction SilentlyContinue|Select-Object -ExpandProperty alllocationsdisabled
if ($tldisable -eq '1')
{
write-host "Trusted Locations for Outlook are disabled" -ForegroundColor Green
}
else
{
write-host "Trusted Locations For Outlook are enabled" -ForegroundColor Yellow
foreach($_ in 1..50)
{
$i++
$trustedlocation = Get-ItemProperty -Path "Registry::HKEY_CURRENT_USER\Software\Policies\Microsoft\Office\$officeversion\Outlook\Security\Trusted Locations\location$_" -Name path -ErrorAction SilentlyContinue|Select-Object -ExpandProperty path
If ($trustedlocation -ne $null)
{
write-host "$trustedlocation" -ForegroundColor Magenta
}
}
}
write-host "`r`n####################### PATCHING #######################`r`n"
write-host "Unable to check patch levels reliably yet, please check the latest office patch manually to ensure patches are up to date" -ForegroundColor Cyan
#Get-ItemProperty HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where {$_.DisplayName -like "*Office*"} | Select-Object DisplayName, DisplayVersion, Publisher, InstallDate | Format-Table –AutoSize
write-host "`r`n####################### ACTIVE-X #######################`r`n"
$disableallactivex = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\common\security" -Name disableallactivex -ErrorAction SilentlyContinue|Select-Object -ExpandProperty disableallactivex
if ($disableallactivex -eq $null)
{
write-host "Disable All ActiveX is not configured" -ForegroundColor Yellow
}
elseif ($disableallactivex -eq '1')
{
write-host "Disable All ActiveX is enabled" -ForegroundColor Green
}
elseif ($disableallactivex -eq '0')
{
write-host "Disable All ActiveX is disabled" -ForegroundColor Red
}
else
{
write-host "Disable All ActiveX is configured to an unknown setting" -ForegroundColor Red
}
write-host "`r`n####################### ADD-INS #######################`r`n"
#Allow mix of policy and user locations
$trustedlocationsmix = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\common\security\trusted locations" -Name 'allow user locations' -ErrorAction SilentlyContinue|Select-Object -ExpandProperty 'allow user locations'
if ($trustedlocationsmix -eq $null)
{
write-host "Allow mix of policy and user locations is not configured" -ForegroundColor Yellow
}
elseif ($trustedlocationsmix -eq '0')
{
write-host "Allow mix of policy and user locations is disabled" -ForegroundColor Green
}
elseif ($trustedlocationsmix -eq '1')
{
write-host "Allow mix of policy and user locations is enabled" -ForegroundColor Red
}
else
{
write-host "Allow mix of policy and user locations is set to an unknown setting" -ForegroundColor Red
}
#Disable all applications add-ins in Excel
$disablealladdinsexcel = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\excel\security" -Name disablealladdins -ErrorAction SilentlyContinue|Select-Object -ExpandProperty disablealladdins
if ($disablealladdinsexcel -eq $null)
{
write-host "Disable all applications add-ins in Excel is not configured" -ForegroundColor Yellow
}
elseif ($disablealladdinsexcel -eq '1')
{
write-host "Disable all applications add-ins in Excel is enabled" -ForegroundColor Green
#Allow Trusted Locations on the network
$allowtrustedlocationsexcel2 = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\excel\security\trusted locations" -Name allownetworklocations -ErrorAction SilentlyContinue|Select-Object -ExpandProperty allownetworklocations
if ($allowtrustedlocationsexcel2 -eq $null)
{
write-host "Allow Trusted Locations on the network in Excel is not configured" -ForegroundColor Yellow
}
elseif ($allowtrustedlocationsexcel2 -eq '0')
{
write-host "Allow Trusted Locations on the network in Excel is disabled" -ForegroundColor Green
}
elseif ($allowtrustedlocationsexcel2 -eq '1')
{
write-host "Allow Trusted Locations on the network in Excel is enabled" -ForegroundColor Red
}
#Disable all trusted locations
$alllocationsdisabledexcel2 = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\excel\security\trusted locations" -Name alllocationsdisabled -ErrorAction SilentlyContinue|Select-Object -ExpandProperty alllocationsdisabled
if ($alllocationsdisabledexcel2 -eq $null)
{
write-host "Disable all trusted locations in Excel is not configured" -ForegroundColor Yellow
}
elseif ($alllocationsdisabledexcel2 -eq '0')
{
write-host "Disable all trusted locations in Excel is disabled" -ForegroundColor Red
}
elseif ($alllocationsdisabledexcel2 -eq '1')
{
write-host "Disable all trusted locations in Excel is enabled" -ForegroundColor Green
}
}
elseif ($disablealladdinsexcel -eq '0')
{
write-host "Disable all applications add-ins in Excel is disabled, this setting is compliant if you explicitly need add-ins" -ForegroundColor Green
#Disable Trust Bar Notification for unsigned application add-ins and block them
$disabletrustbarexcel = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\excel\security" -Name notbpromptunsignedaddin -ErrorAction SilentlyContinue|Select-Object -ExpandProperty notbpromptunsignedaddin
if ($disabletrustbarexcel -eq $null)
{
write-host "Disable Trust Bar Notification for unsigned application add-ins and block them in Excel is not configured" -ForegroundColor Yellow
}
elseif ($disabletrustbarexcel -eq '0')
{
write-host "Disable Trust Bar Notification for unsigned application add-ins and block them in Excel is disabled" -ForegroundColor Red
}
elseif ($disabletrustbarexcel -eq '1')
{
write-host "Disable Trust Bar Notification for unsigned application add-ins and block them in Excel is enabled" -ForegroundColor Green
}
#Require that application add-ins are signed by Trusted Publisher
$requireaddinsigexcel = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\excel\security" -Name requireaddinsig -ErrorAction SilentlyContinue|Select-Object -ExpandProperty requireaddinsig
if ($requireaddinsigexcel -eq $null)
{
write-host "Require that application add-ins are signed by Trusted Publisher in Excel is not configured" -ForegroundColor Yellow
}
elseif ($requireaddinsigexcel -eq '0')
{
write-host "Require that application add-ins are signed by Trusted Publisher in Excel is disabled" -ForegroundColor Red
}
elseif ($requireaddinsigexcel -eq '1')
{
write-host "Require that application add-ins are signed by Trusted Publisher in Excel is enabled" -ForegroundColor Green
}
#Allow Trusted Locations on the network
$allowtrustedlocationsexcel1 = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\excel\security\trusted locations" -Name allownetworklocations -ErrorAction SilentlyContinue|Select-Object -ExpandProperty allownetworklocations
if ($allowtrustedlocationsexcel1 -eq $null)
{
write-host "Allow Trusted Locations on the network in Excel is not configured" -ForegroundColor Yellow
}
elseif ($allowtrustedlocationsexcel1 -eq '0')
{
write-host "Allow Trusted Locations on the network in Excel is disabled" -ForegroundColor Red
}
elseif ($allowtrustedlocationsexcel1 -eq '1')
{
write-host "Allow Trusted Locations on the network in Excel is enabled" -ForegroundColor Green
}
#Disable all trusted locations
$alllocationsdisabledexcel1 = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\excel\security\trusted locations" -Name alllocationsdisabled -ErrorAction SilentlyContinue|Select-Object -ExpandProperty alllocationsdisabled
if ($alllocationsdisabledexcel1 -eq $null)
{
write-host "Disable all trusted locations in Excel is not configured" -ForegroundColor Yellow
}
elseif ($alllocationsdisabledexcel1 -eq '0')
{
write-host "Disable all trusted locations in Excel is disabled" -ForegroundColor Green
}
elseif ($alllocationsdisabledexcel1 -eq '1')
{
write-host "Disable all trusted locations in Excel is enabled" -ForegroundColor Red
}
}
else
{
write-host "Disable all applications add-ins in Excel is set to an unknown setting" -ForegroundColor Red
}
#Disable all applications add-ins in Powerpoint
$disablealladdinspowerpoint = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\powerpoint\security" -Name disablealladdins -ErrorAction SilentlyContinue|Select-Object -ExpandProperty disablealladdins
if ($disablealladdinspowerpoint -eq $null)
{
write-host "Disable all applications add-ins in powerpoint is not configured" -ForegroundColor Yellow
}
elseif ($disablealladdinspowerpoint -eq '1')
{
write-host "Disable all applications add-ins in powerpoint is enabled" -ForegroundColor Green
#Allow Trusted Locations on the network
$allowtrustedlocationspowerpoint2 = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\powerpoint\security\trusted locations" -Name allownetworklocations -ErrorAction SilentlyContinue|Select-Object -ExpandProperty allownetworklocations
if ($allowtrustedlocationspowerpoint2 -eq $null)
{
write-host "Allow Trusted Locations on the network in powerpoint is not configured" -ForegroundColor Yellow
}
elseif ($allowtrustedlocationspowerpoint2 -eq '0')
{
write-host "Allow Trusted Locations on the network in powerpoint is disabled" -ForegroundColor Green
}
elseif ($allowtrustedlocationspowerpoint2 -eq '1')
{
write-host "Allow Trusted Locations on the network in powerpoint is enabled" -ForegroundColor Red
}
#Disable all trusted locations
$alllocationsdisabledpowerpoint2 = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\powerpoint\security\trusted locations" -Name alllocationsdisabled -ErrorAction SilentlyContinue|Select-Object -ExpandProperty alllocationsdisabled
if ($alllocationsdisabledpowerpoint2 -eq $null)
{
write-host "Disable all trusted locations in powerpoint is not configured" -ForegroundColor Yellow
}
elseif ($alllocationsdisabledpowerpoint2 -eq '0')
{
write-host "Disable all trusted locations in powerpoint is disabled" -ForegroundColor Red
}
elseif ($alllocationsdisabledpowerpoint2 -eq '1')
{
write-host "Disable all trusted locations in powerpoint is enabled" -ForegroundColor Green
}
}
elseif ($disablealladdinspowerpoint -eq '0')
{
write-host "Disable all applications add-ins in powerpoint is disabled, this setting is compliant if you explicitly need add-ins" -ForegroundColor Green
#Disable Trust Bar Notification for unsigned application add-ins and block them
$disabletrustbarpowerpoint = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\powerpoint\security" -Name notbpromptunsignedaddin -ErrorAction SilentlyContinue|Select-Object -ExpandProperty notbpromptunsignedaddin
if ($disabletrustbarpowerpoint -eq $null)
{
write-host "Disable Trust Bar Notification for unsigned application add-ins and block them in powerpoint is not configured" -ForegroundColor Yellow
}
elseif ($disabletrustbarpowerpoint -eq '0')
{
write-host "Disable Trust Bar Notification for unsigned application add-ins and block them in powerpoint is disabled" -ForegroundColor Red
}
elseif ($disabletrustbarpowerpoint -eq '1')
{
write-host "Disable Trust Bar Notification for unsigned application add-ins and block them in powerpoint is enabled" -ForegroundColor Green
}
#Require that application add-ins are signed by Trusted Publisher
$requireaddinsigpowerpoint = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\powerpoint\security" -Name requireaddinsig -ErrorAction SilentlyContinue|Select-Object -ExpandProperty requireaddinsig
if ($requireaddinsigpowerpoint -eq $null)
{
write-host "Require that application add-ins are signed by Trusted Publisher in powerpoint is not configured" -ForegroundColor Yellow
}
elseif ($requireaddinsigpowerpoint -eq '0')
{
write-host "Require that application add-ins are signed by Trusted Publisher in powerpoint is disabled" -ForegroundColor Red
}
elseif ($requireaddinsigpowerpoint -eq '1')
{
write-host "Require that application add-ins are signed by Trusted Publisher in powerpoint is enabled" -ForegroundColor Green
}
#Allow Trusted Locations on the network
$allowtrustedlocationspowerpoint1 = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\powerpoint\security\trusted locations" -Name allownetworklocations -ErrorAction SilentlyContinue|Select-Object -ExpandProperty allownetworklocations
if ($allowtrustedlocationspowerpoint1 -eq $null)
{
write-host "Allow Trusted Locations on the network in powerpoint is not configured" -ForegroundColor Yellow
}
elseif ($allowtrustedlocationspowerpoint1 -eq '0')
{
write-host "Allow Trusted Locations on the network in powerpoint is disabled" -ForegroundColor Red
}
elseif ($allowtrustedlocationspowerpoint1 -eq '1')
{
write-host "Allow Trusted Locations on the network in powerpoint is enabled" -ForegroundColor Green
}
#Disable all trusted locations
$alllocationsdisabledpowerpoint1 = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\powerpoint\security\trusted locations" -Name alllocationsdisabled -ErrorAction SilentlyContinue|Select-Object -ExpandProperty alllocationsdisabled
if ($alllocationsdisabledpowerpoint1 -eq $null)
{
write-host "Disable all trusted locations in powerpoint is not configured" -ForegroundColor Yellow
}
elseif ($alllocationsdisabledpowerpoint1 -eq '0')
{
write-host "Disable all trusted locations in powerpoint is disabled" -ForegroundColor Green
}
elseif ($alllocationsdisabledpowerpoint1 -eq '1')
{
write-host "Disable all trusted locations in powerpoint is enabled" -ForegroundColor Red
}
}
else
{
write-host "Disable all applications add-ins in powerpoint is set to an unknown setting" -ForegroundColor Red
}
#Disable all applications add-ins in Word
$disablealladdinsWord = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\Word\security" -Name disablealladdins -ErrorAction SilentlyContinue|Select-Object -ExpandProperty disablealladdins
if ($disablealladdinsWord -eq $null)
{
write-host "Disable all applications add-ins in Word is not configured" -ForegroundColor Yellow
}
elseif ($disablealladdinsWord -eq '1')
{
write-host "Disable all applications add-ins in Word is enabled" -ForegroundColor Green
#Allow Trusted Locations on the network
$allowtrustedlocationsWord2 = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\Word\security\trusted locations" -Name allownetworklocations -ErrorAction SilentlyContinue|Select-Object -ExpandProperty allownetworklocations
if ($allowtrustedlocationsWord2 -eq $null)
{
write-host "Allow Trusted Locations on the network in Word is not configured" -ForegroundColor Yellow
}
elseif ($allowtrustedlocationsWord2 -eq '0')
{
write-host "Allow Trusted Locations on the network in Word is disabled" -ForegroundColor Green
}
elseif ($allowtrustedlocationsWord2 -eq '1')
{
write-host "Allow Trusted Locations on the network in Word is enabled" -ForegroundColor Red
}
#Disable all trusted locations
$alllocationsdisabledWord2 = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\Word\security\trusted locations" -Name alllocationsdisabled -ErrorAction SilentlyContinue|Select-Object -ExpandProperty alllocationsdisabled
if ($alllocationsdisabledWord2 -eq $null)
{
write-host "Disable all trusted locations in Word is not configured" -ForegroundColor Yellow
}
elseif ($alllocationsdisabledWord2 -eq '0')
{
write-host "Disable all trusted locations in Word is disabled" -ForegroundColor Red
}
elseif ($alllocationsdisabledWord2 -eq '1')
{
write-host "Disable all trusted locations in Word is enabled" -ForegroundColor Green
}
}
elseif ($disablealladdinsWord -eq '0')
{
write-host "Disable all applications add-ins in Word is disabled, this setting is compliant if you explicitly need add-ins" -ForegroundColor Green
#Disable Trust Bar Notification for unsigned application add-ins and block them
$disabletrustbarWord = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\Word\security" -Name notbpromptunsignedaddin -ErrorAction SilentlyContinue|Select-Object -ExpandProperty notbpromptunsignedaddin
if ($disabletrustbarWord -eq $null)
{
write-host "Disable Trust Bar Notification for unsigned application add-ins and block them in Word is not configured" -ForegroundColor Yellow
}
elseif ($disabletrustbarWord -eq '0')
{
write-host "Disable Trust Bar Notification for unsigned application add-ins and block them in Word is disabled" -ForegroundColor Red
}
elseif ($disabletrustbarWord -eq '1')
{
write-host "Disable Trust Bar Notification for unsigned application add-ins and block them in Word is enabled" -ForegroundColor Green
}
#Require that application add-ins are signed by Trusted Publisher
$requireaddinsigWord = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\Word\security" -Name requireaddinsig -ErrorAction SilentlyContinue|Select-Object -ExpandProperty requireaddinsig
if ($requireaddinsigWord -eq $null)
{
write-host "Require that application add-ins are signed by Trusted Publisher in Word is not configured" -ForegroundColor Yellow
}
elseif ($requireaddinsigWord -eq '0')
{
write-host "Require that application add-ins are signed by Trusted Publisher in Word is disabled" -ForegroundColor Red
}
elseif ($requireaddinsigWord -eq '1')
{
write-host "Require that application add-ins are signed by Trusted Publisher in Word is enabled" -ForegroundColor Green
}
#Allow Trusted Locations on the network
$allowtrustedlocationsWord1 = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\Word\security\trusted locations" -Name allownetworklocations -ErrorAction SilentlyContinue|Select-Object -ExpandProperty allownetworklocations
if ($allowtrustedlocationsWord1 -eq $null)
{
write-host "Allow Trusted Locations on the network in Word is not configured" -ForegroundColor Yellow
}
elseif ($allowtrustedlocationsWord1 -eq '0')
{
write-host "Allow Trusted Locations on the network in Word is disabled" -ForegroundColor Red
}
elseif ($allowtrustedlocationsWord1 -eq '1')
{
write-host "Allow Trusted Locations on the network in Word is enabled" -ForegroundColor Green
}
#Disable all trusted locations
$alllocationsdisabledWord1 = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\Word\security\trusted locations" -Name alllocationsdisabled -ErrorAction SilentlyContinue|Select-Object -ExpandProperty alllocationsdisabled
if ($alllocationsdisabledWord1 -eq $null)
{
write-host "Disable all trusted locations in Word is not configured" -ForegroundColor Yellow
}
elseif ($alllocationsdisabledWord1 -eq '0')
{
write-host "Disable all trusted locations in Word is disabled" -ForegroundColor Green
}
elseif ($alllocationsdisabledWord1 -eq '1')
{
write-host "Disable all trusted locations in Word is enabled" -ForegroundColor Red
}
}
else
{
write-host "Disable all applications add-ins in Word is set to an unknown setting" -ForegroundColor Red
}
write-host "`r`n####################### EXTENSION HARDENING #######################`r`n"
$extensionhardening = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\excel\security" -Name extensionhardening -ErrorAction SilentlyContinue|Select-Object -ExpandProperty extensionhardening
if ($extensionhardening -eq $null)
{
write-host "Make hidden markup visible for Powerpoint is not configured" -ForegroundColor Yellow
}
elseif ($extensionhardening -eq '0')
{
write-host "Extension hardening for Excel is enabled, however it is set to Allow Different which is a non-compliant setting. The compliant setting is always match file type" -ForegroundColor Red
}
elseif ($extensionhardening -eq '1')
{
write-host "Extension hardening for Excel is enabled, however it is set to Allow Different, but warn which is a non-compliant setting. The compliant setting is always match file type" -ForegroundColor Red
}
elseif ($extensionhardening -eq '2')
{
write-host "Extension hardening for Excel is enabled and set to Always match file type" -ForegroundColor Green
}
else
{
write-host "Extension hardening for Excel is set to an unknown setting" -ForegroundColor Red
}
write-host "`r`n####################### FILE TYPE BLOCKING #######################`r`n"
$dbasefiles = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\excel\security\fileblock" -Name dbasefiles -ErrorAction SilentlyContinue|Select-Object -ExpandProperty dbasefiles
if ($dbasefiles -eq $null)
{
write-host "File Type Blocking for dBase III / IV files in Excel is not configured" -ForegroundColor Yellow
}
elseif ($dbasefiles -eq '0')
{
write-host "Do not block for dBase III / IV files in Excel is set to 'do not block'" -ForegroundColor Red
}
elseif ($dbasefiles -eq '2')
{
write-host "Do not block for dBase III / IV files in Excel is set to 'Open/Save blocked, use open policy'" -ForegroundColor Red
}
else
{
write-host "Do not block for dBase III / IV files in Excel is set to an unknown setting" -ForegroundColor Red
}
$difandsylkfiles = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\excel\security\fileblock" -Name difandsylkfiles -ErrorAction SilentlyContinue|Select-Object -ExpandProperty difandsylkfiles
if ($difandsylkfiles -eq $null)
{
write-host "File Type Blocking for Dif and Sylk files in Excel is not configured" -ForegroundColor Yellow
}
elseif ($difandsylkfiles -eq '0')
{
write-host "File Type Blocking for Dif and Sylk files in Excel is set to 'do not block'" -ForegroundColor Red
}
elseif ($difandsylkfiles -eq '1')
{
write-host "File Type Blocking for Dif and Sylk files in Excel is set to 'Save Blocked''" -ForegroundColor Red
}
elseif ($difandsylkfiles -eq '2')
{
write-host "File Type Blocking for Dif and Sylk files in Excel is set to 'Open/Save blocked, use open policy'" -ForegroundColor Red
}
else
{
write-host "File Type Blocking for Dif and Sylk files in Excel is set to an unknown setting" -ForegroundColor Red
}
$xl2macros = Get-ItemProperty -Path "Registry::HKCU\software\policies\microsoft\office\$officeversion\excel\security\fileblock" -Name xl2macros -ErrorAction SilentlyContinue|Select-Object -ExpandProperty xl2macros
if ($xl2macros -eq $null)
{
write-host "File Type Blocking for Excel 2 macrosheets and add-in files is not configured" -ForegroundColor Yellow
}
elseif ($xl2macros -eq '0')
{
write-host "File Type Blocking for Excel 2 macrosheets and add-in files is set to 'do not block'" -ForegroundColor Red
}
elseif ($xl2macros -eq '1')
{
write-host "File Type Blocking for Excel 2 macrosheets and add-in files is set to 'Save Blocked''" -ForegroundColor Red
}
elseif ($xl2macros -eq '2')