forked from cottinghamd/HardeningAuditor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ASD1709HardeningComplianceCheck.ps1
6463 lines (5675 loc) · 285 KB
/
ASD1709HardeningComplianceCheck.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
#ASD Hardening Microsoft Windows 10, version 1709 Workstations compliance script. This script will check the applied settings in the current user context.
#This script is based on the settings recommended in the ASD Hardening Guide here: https://www.asd.gov.au/publications/protect/Hardening_Win10.pdf
#Created by github.com/cottinghamd and github.com/huda008
#Incorporated Invoke-ElevatedCommand by TaoK https://gist.github.com/TaoK/1582185
If ($isDotSourced = $MyInvocation.InvocationName -eq '.' -or $MyInvocation.Line -eq '')
{
#donothingandcontinue
}
else
{
write-host "This script was not run 'dot sourced'. For this script to execute correctly, please ensure the script is dot sourced e.g. use . .\ASD1709HardeningComplianceCheck.ps1" -Foregroundcolor Red
write-host "This script will now exit" -Foregroundcolor Red
break
}
Function Invoke-ElevatedCommand {
param
(
## The script block to invoke elevated. NOTE: to access the InputObject/pipeline data from the script block, use "$input"!
[Parameter(Mandatory = $true)]
[ScriptBlock] $Scriptblock,
## Any input to give the elevated process
[Parameter(ValueFromPipeline = $true)]
$InputObject,
## Switch to enable the user profile
[switch] $EnableProfile,
## Switch to display the spawned window (as interactive)
[switch] $DisplayWindow
)
begin
{
Set-StrictMode -Version Latest
$inputItems = New-Object System.Collections.ArrayList
}
process
{
$null = $inputItems.Add($inputObject)
}
end
{
## Create some temporary files for streaming input and output
$outputFile = [IO.Path]::GetTempFileName()
$inputFile = [IO.Path]::GetTempFileName()
$errorFile = [IO.Path]::GetTempFileName()
## Stream the input into the input file
$inputItems.ToArray() | Export-CliXml -Depth 1 $inputFile
## Start creating the command line for the elevated PowerShell session
$commandLine = ""
if(-not $EnableProfile) { $commandLine += "-NoProfile " }
if(-not $DisplayWindow) {
$commandLine += "-Noninteractive "
$processWindowStyle = "Hidden"
}
else {
$processWindowStyle = "Normal"
}
## Convert the command into an encoded command for PowerShell
$commandString = "Set-Location '$($pwd.Path)'; " +
"`$output = Import-CliXml '$inputFile' | " +
"& {" + $scriptblock.ToString() + "} 2>&1 ; " +
"Out-File -filepath '$errorFile' -inputobject `$error;" +
"Export-CliXml -Depth 1 -In `$output '$outputFile';"
$commandBytes = [System.Text.Encoding]::Unicode.GetBytes($commandString)
$encodedCommand = [Convert]::ToBase64String($commandBytes)
$commandLine += "-EncodedCommand $encodedCommand"
## Start the new PowerShell process
$process = Start-Process -FilePath (Get-Command powershell).Definition `
-ArgumentList $commandLine `
-Passthru `
-Verb RunAs `
-WindowStyle $processWindowStyle
$process.WaitForExit()
$errorMessage = $(gc $errorFile | Out-String)
if($errorMessage) {
Write-Error -Message $errorMessage
}
else {
## Return the output to the user
if((Get-Item $outputFile).Length -gt 0)
{
Import-CliXml $outputFile
}
}
## Clean up
Remove-Item $outputFile
Remove-Item $inputFile
Remove-Item $errorFile
}
}
Function Get-MachineType
{
[CmdletBinding()]
[OutputType([int])]
Param
(
# ComputerName
[Parameter(Mandatory=$false,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
Position=0)]
[string[]]$ComputerName=$env:COMPUTERNAME,
$Credential = [System.Management.Automation.PSCredential]::Empty
)
Begin
{
}
Process
{
foreach ($Computer in $ComputerName) {
Write-Verbose "Checking $Computer"
try {
$hostdns = [System.Net.DNS]::GetHostEntry($Computer)
$ComputerSystemInfo = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $Computer -ErrorAction Stop -Credential $Credential
switch ($ComputerSystemInfo.Model) {
# Check for Hyper-V Machine Type
"Virtual Machine" {
$MachineType="VM"
}
# Check for VMware Machine Type
"VMware Virtual Platform" {
$MachineType="VM"
}
# Check for Oracle VM Machine Type
"VirtualBox" {
$MachineType="VM"
}
# Otherwise it is a physical Box
default {
$MachineType="Physical"
}
}
# Building MachineTypeInfo Object
$MachineTypeInfo = New-Object -TypeName PSObject -Property ([ordered]@{
ComputerName=$ComputerSystemInfo.PSComputername
Type=$MachineType
Manufacturer=$ComputerSystemInfo.Manufacturer
Model=$ComputerSystemInfo.Model
})
$MachineTypeInfo
}
catch [Exception] {
Write-Output "$Computer`: $($_.Exception.Message)"
}
}
}
End
{
}
}
Function outputanswer($answer,$color)
{
if($global:displayconsole -eq 'y')
{
if ($color -eq 'White')
{
write-host "`r`n#######################" $answer "#######################`r`n" -ForegroundColor $color
}
else
{
write-host $answer -ForegroundColor $color
}
}
if ($color -eq 'Yellow')
{
$compliance = 'Non-Compliant (Due to Non-Configuration)'
}
elseif ($color -eq 'Green')
{
$compliance = 'Compliant'
}
elseif ($color -eq 'Red')
{
$compliance = 'Non-Compliant'
}
elseif ($color -eq 'White')
{
$global:chapter = $answer
$answer = $null
}
elseif ($color -eq 'Cyan')
{
$compliance = 'Unknown'
}
$global:report += New-Object psobject -Property @{Chapter=$chapter;Compliance=$compliance;Setting=$answer}
}
Write-Host "ASD Hardening Microsoft Windows 10, version 1709 Workstations compliance script" -ForegroundColor Green
Write-Host "This script is based on the settings recommended in the ASD Hardening Guide here: https://www.asd.gov.au/publications/protect/Hardening_Win10.pdf" -ForegroundColor Green
Write-Host "Created by github.com/cottinghamd and github.com/huda008" -ForegroundColor Green
If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
{
$adminprivs = Read-Host "`r`nAdministrative privileges have not been detected, do you want to elevate now and pre-check controls that require administrative privileges? (y/n)"
If ($adminprivs -eq 'y')
{
$Checkelevateditems = 'y'
}
else
{
#donothing
}
}
else
{
$Checkelevateditems = 'y'
}
If ($Checkelevateditems -eq 'y')
{
#Get Current User Temp Directory For Writing Between Contexts
$userenvironmenttemp = ${env:TEMP}
#this statement is now ready to check multiple elevated controls
$secureboottemp = $userenvironmenttemp
Invoke-ElevatedCommand -InputObject $userenvironmenttemp {
$temppath = "$input"
#check secure boot Elevated
$secureboot = "$temppath" + '\secureboot.txt'
Confirm-SecureBootUEFI | Out-File $secureboot
#check Allow Anonymous SID / Name Translation Elevated
$lsaanonymousnamelookup = "$temppath" + '\lsaanonymousnamelookup.txt'
$null = secedit /export /cfg $temppath/secexport.cfg
$(gc $temppath/secexport.cfg | Select-String "LSAAnonymousNameLookup").ToString().Split('=')[1].Trim() | Out-File $lsaanonymousnamelookup
Remove-Item $temppath/secexport.cfg
}
}
$report = @()
$writetype = Read-Host "`r`nDo you want to output this scripts results to a file? (y for Yes or n for No)"
If ($writetype -eq 'y')
{
$tooutput = 'y'
$working = Get-Location
$workingdirok = Read-Host "`r`nThe output file will be output to the following location $working\results.csv, is this ok? (y for Yes or n for No)"
If ($workingdirok -eq 'y')
{
$filepath = "$working\results.csv"
}
else
{
$filepath = Read-Host "`r`naPlease specify the full output file path here e.g. C:\logs\output.csv"
}
}
$displayconsole = Read-Host "`r`nDo you want the output to also be displayed in the console? (y for Yes or n for No)"
outputanswer -answer "CREDENTIAL CACHING" -color White
outputanswer -answer "This script is unable to check Number of Previous Logons to cache, this is because the setting is in the security registry hive, please check the GPO located at Computer Configuration\Policies\Windows Settings\Security Settings\Local Policies\Security Options\Interactive Logon" -color Cyan
#Check Network Access: Do not allow storage of passwords and credentials for network authentication
$networkaccess = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa\" -Name disabledomaincreds -ErrorAction SilentlyContinue|Select-Object -ExpandProperty disabledomaincreds
if ($networkaccess -eq $null)
{
outputanswer -answer "Do not allow storage of passwords and credentials for network authentication is not configured" -color Yellow
}
elseif ($networkaccess -eq '1')
{
outputanswer -answer "Do not allow storage of passwords and credentials for network authentication is enabled" -color Green
}
else
{
outputanswer -answer "Do not allow storage of passwords and credentials for network authentication is disabled" -color Red
}
#Check WDigestAuthentication is disabled
$wdigest = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\Wdigest\" -Name uselogoncredential -ErrorAction SilentlyContinue|Select-Object -ExpandProperty uselogoncredential
if ($wdigest -eq $null)
{
outputanswer -answer "WDigest is not configured" -color Yellow
}
elseif ($wdigest -eq '0')
{
outputanswer -answer "WDigest is disabled" -color Green
}
else
{
outputanswer -answer "WDigest is enabled" -color Red
}
#Check Turn on Virtualisation Based Security
$vbsecurity = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DeviceGuard\" -Name EnableVirtualizationBasedSecurity -ErrorAction SilentlyContinue|Select-Object -ExpandProperty EnableVirtualizationBasedSecurity
if ($vbsecurity -eq $null)
{
outputanswer -answer "Virtualisation Based Security is not configured" -color Yellow
}
elseif ($vbsecurity -eq '1')
{
outputanswer -answer "Virtualisation Based security is enabled" -color Green
}
else
{
outputanswer -answer "Virtualisation Based security is disabled" -color Red
}
#Check Secure Boot and DMA Protection
$sbdmaprot = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DeviceGuard" -Name RequirePlatformSecurityFeatures -ErrorAction SilentlyContinue|Select-Object -ExpandProperty RequirePlatformSecurityFeatures
if ($sbdmaprot -eq $null)
{
outputanswer -answer "Secure Boot and DMA Protection is not configured" -color Yellow
}
elseif ($sbdmaprot -eq '3')
{
outputanswer -answer "Secure Boot and DMA Protection is enabled" -color Green
}
else
{
outputanswer -answer "Secure Boot and DMA Protection is set to something non compliant" -color Red
}
#Check UEFI Lock is enabled for device guard
$uefilock = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\DeviceGuard" -Name LsaCfgFlags -ErrorAction SilentlyContinue|Select-Object -ExpandProperty LsaCfgFlags
if ($uefilock -eq $null)
{
outputanswer -answer "Virtualisation Based Protection of Code Integrity with UEFI lock is not configured" -color Yellow
}
elseif ($uefilock -eq '1')
{
outputanswer -answer "Virtualisation Based Protection of Code Integrity with UEFI lock is enabled" -color Green
}
else
{
outputanswer -answer "Virtualisation Based Protection of Code Integrity with UEFI lock is set to something non compliant" -color Red
}
outputanswer -answer "CONTROLLED FOLDER ACCESS" -color White
#Check Controlled Folder Access for Exploit Guard is Enabled
$cfaccess = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Defender\Exploit Guard\Controlled Folder Access" -Name EnableControlledFolderAccess -ErrorAction SilentlyContinue|Select-Object -ExpandProperty EnableControlledFolderAccess
if ($cfaccess -eq $null)
{
outputanswer -answer "Controlled Folder Access for Exploit Guard is not configured" -color Yellow
}
elseif ($cfaccess -eq '1')
{
outputanswer -answer "Controlled Folder Access for Exploit Guard is enabled" -color Green
}
else
{
outputanswer -answer "Controlled Folder Access for Exploit Guard is disabled" -color Red
}
outputanswer -answer "CREDENTIAL ENTRY" -color White
#Check Do not display network selection UI
$netselectui = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\System" -Name DontDisplayNetworkSelectionUI -ErrorAction SilentlyContinue|Select-Object -ExpandProperty DontDisplayNetworkSelectionUI
if ($netselectui -eq $null)
{
outputanswer -answer "Do not display network selection UI is not configured" -color Yellow
}
elseif ($netselectui -eq '1')
{
outputanswer -answer "Do not display network selection UI is enabled" -color Green
}
else
{
outputanswer -answer "Do not display network selection UI is disabled" -color Red
}
#Check Enumerate local users on domain joined computers
$enumlocalusers = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\System" -Name EnumerateLocalUsers -ErrorAction SilentlyContinue|Select-Object -ExpandProperty EnumerateLocalUsers
if ($enumlocalusers -eq $null)
{
outputanswer -answer "Enumerate local users on domain joined computers is not configured" -color Yellow
}
elseif ($enumlocalusers -eq '0')
{
outputanswer -answer "Enumerate local users on domain joined computers is enabled" -color Green
}
else
{
outputanswer -answer "Enumerate local users on domain joined computers is disabled" -color Red
}
#Check Do not display the password reveal button
$disablepassreveal = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\CredUI" -Name DisablePasswordReveal -ErrorAction SilentlyContinue|Select-Object -ExpandProperty DisablePasswordReveal
if ($disablepassreveal -eq $null)
{
outputanswer -answer "Do not display the password reveal button is not configured" -color Yellow
}
elseif ($disablepassreveal -eq '1')
{
outputanswer -answer "Do not display the password reveal button is enabled" -color Green
}
else
{
outputanswer -answer "Do not display the password reveal button is disabled" -color Red
}
#Check Enumerate administrator accounts on elevation
$enumerateadmins = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\CredUI" -Name EnumerateAdministrators -ErrorAction SilentlyContinue|Select-Object -ExpandProperty EnumerateAdministrators
if ($enumerateadmins -eq $null)
{
outputanswer -answer "Enumerate administrator accounts on elevation is not configured" -color Yellow
}
elseif ($enumerateadmins -eq '0')
{
outputanswer -answer "Enumerate administrator accounts on elevation is disabled" -color Green
}
else
{
outputanswer -answer "Enumerate administrator accounts on elevation is enabled" -color Red
}
#Check Require trusted path for credential entry
$credentry = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\CredUI" -Name EnableSecureCredentialPrompting -ErrorAction SilentlyContinue|Select-Object -ExpandProperty EnableSecureCredentialPrompting
if ($credentry -eq $null)
{
outputanswer -answer "Require trusted path for credential entry is not configured" -color Yellow
}
elseif ($credentry -eq '1')
{
outputanswer -answer "Require trusted path for credential entry is enabled" -color Green
}
else
{
outputanswer -answer "Require trusted path for credential entry is disabled" -color Red
}
#Check Disable or enable software Secure Attention Sequence
$sasgeneration = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name SoftwareSASGeneration -ErrorAction SilentlyContinue|Select-Object -ExpandProperty SoftwareSASGeneration
if ($sasgeneration -eq $null)
{
outputanswer -answer "Disable or enable software Secure Attention Sequence is not configured or disabled" -color Green
}
elseif ($sasgeneration -eq '0')
{
outputanswer -answer "Disable or enable software Secure Attention Sequence is disabled" -color Green
}
else
{
outputanswer -answer "Disable or enable software Secure Attention Sequence is enabled" -color Red
}
#Check Sign-in last interactive user automatically after a system-initiated restart
$systeminitiated = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name DisableAutomaticRestartSignOn -ErrorAction SilentlyContinue|Select-Object -ExpandProperty DisableAutomaticRestartSignOn
if ($systeminitiated -eq $null)
{
outputanswer -answer "Sign-in last interactive user automatically after a system-initiated restart is not configured" -color Yellow
}
elseif ($systeminitiated -eq '1')
{
outputanswer -answer "Sign-in last interactive user automatically after a system-initiated restart is disabled" -color Green
}
else
{
outputanswer -answer "Sign-in last interactive user automatically after a system-initiated restart is enabled" -color Red
}
#Check Interactive logon: Do not require CTRL+ALT+DEL
$ctrlaltdel = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name DisableCAD -ErrorAction SilentlyContinue|Select-Object -ExpandProperty DisableCAD
if ($ctrlaltdel -eq $null)
{
outputanswer -answer "Interactive logon: Do not require CTRL+ALT+DEL is not configured" -color Yellow
}
elseif ($ctrlaltdel -eq '0')
{
outputanswer -answer "Interactive logon: Do not require CTRL+ALT+DEL is disabled" -color Green
}
else
{
outputanswer -answer "Interactive logon: Do not require CTRL+ALT+DEL is enabled" -color Red
}
#Check Interactive logon: Don't display username at sign-in
$dontdisplaylastuser = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name DontDisplayLastUserName -ErrorAction SilentlyContinue|Select-Object -ExpandProperty DontDisplayLastUserName
if ($dontdisplaylastuser -eq $null)
{
outputanswer -answer "Interactive logon: Don't display username at sign-in is not configured" -color Yellow
}
elseif ($dontdisplaylastuser -eq '1')
{
outputanswer -answer "Interactive logon: Don't display username at sign-in is enabled" -color Green
}
else
{
outputanswer -answer "Interactive logon: Don't display username at sign-in is disabled" -color Red
}
outputanswer -answer "EARLY LAUNCH ANTI MALWARE" -color White
#Check ELAM Configuration
$elam = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Policies\EarlyLaunch" -Name DriverLoadPolicy -ErrorAction SilentlyContinue|Select-Object -ExpandProperty DriverLoadPolicy
if ($elam -eq $null)
{
outputanswer -answer "ELAM Boot-Start Driver Initialization Policy is not configured" -color Yellow
}
elseif ($elam -eq '8')
{
outputanswer -answer "ELAM Boot-Start Driver Initialization Policy is enabled and set to Good Only" -color Green
}
elseif ($elam -eq '2' -or $elam -eq '1')
{
outputanswer -answer "ELAM Boot-Start Driver Initialization Policy is enabled and set to Good and Unknown" -color Green
}
elseif ($elam -eq '3')
{
outputanswer -answer "ELAM Boot-Start Driver Initialization Policy is enabled, but set to Good, Unknown, Bad but critical" -color Red
}
elseif ($elam -eq '7')
{
outputanswer -answer "ELAM Boot-Start Driver Initialization Policy is enabled, but set allow All drivers" -color Red
}
else
{
outputanswer -answer "ELAM Boot-Start Driver Initialization Policy is disabled" -color Red
}
outputanswer -answer "ELEVATING PRIVILEGES" -color White
#User Account Control: Admin Approval Mode for the Built-in Administrator account
$adminapprovalmode = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name FilterAdministratorToken -ErrorAction SilentlyContinue|Select-Object -ExpandProperty FilterAdministratorToken
if ($adminapprovalmode -eq $null)
{
outputanswer -answer "Admin Approval Mode for the Built-in Administrator account is not configured" -color Yellow
}
elseif ($adminapprovalmode -eq '1')
{
outputanswer -answer "Admin Approval Mode for the Built-in Administrator account is enabled" -color Green
}
else
{
outputanswer -answer "Admin Approval Mode for the Built-in Administrator account is disabled" -color Red
}
#User Account Control: Allow UIAccess applications to prompt for elevation without using the secure desktop
$uiaccessapplications = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name EnableUIADesktopToggle -ErrorAction SilentlyContinue|Select-Object -ExpandProperty EnableUIADesktopToggle
if ($uiaccessapplications -eq $null)
{
outputanswer -answer "Allow UIAccess applications to prompt for elevation without using the secure desktop is not configured" -color Yellow
}
elseif ($uiaccessapplications -eq '0')
{
outputanswer -answer "Allow UIAccess applications to prompt for elevation without using the secure desktop is disabled" -color Green
}
else
{
outputanswer -answer "Allow UIAccess applications to prompt for elevation without using the secure desktop is enabled" -color Red
}
#User Account Control: Behavior of the elevation prompt for administrators in Admin Approval Mode
$elevationprompt = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name ConsentPromptBehaviorAdmin -ErrorAction SilentlyContinue|Select-Object -ExpandProperty ConsentPromptBehaviorAdmin
if ($elevationprompt -eq $null)
{
outputanswer -answer "Behavior of the elevation prompt for administrators in Admin Approval Mode is not configured" -color Yellow
}
elseif ($elevationprompt -eq '0')
{
outputanswer -answer "Behavior of the elevation prompt for administrators in Admin Approval Mode is configured, but set to Elevate without prompting" -color Red
}
elseif ($elevationprompt -eq '1')
{
outputanswer -answer "Behavior of the elevation prompt for administrators in Admin Approval Mode is configured and set to Prompt for credentials on the secure desktop" -color Green
}
elseif ($elevationprompt -eq '2')
{
outputanswer -answer "Behavior of the elevation prompt for administrators in Admin Approval Mode is configured, but set to Prompt for consent on the secure desktop" -color Red
}
elseif ($elevationprompt -eq '3')
{
outputanswer -answer "Behavior of the elevation prompt for administrators in Admin Approval Mode is configured, but set to Prompt for credentials" -color Red
}
elseif ($elevationprompt -eq '4')
{
outputanswer -answer "Behavior of the elevation prompt for administrators in Admin Approval Mode is configured, but set to Prompt for consent" -color Red
}
elseif ($elevationprompt -eq '5')
{
outputanswer -answer "Behavior of the elevation prompt for administrators in Admin Approval Mode is configured, but set to Prompt for consent for non-Windows binaries" -color Red
}
else
{
outputanswer -answer "Behavior of the elevation prompt for administrators in Admin Approval Mode is not configured" -color Red
}
#User Account Control: Behavior of the elevation prompt for standard users
$standardelevationprompt = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name ConsentPromptBehaviorUser -ErrorAction SilentlyContinue|Select-Object -ExpandProperty ConsentPromptBehaviorUser
if ($standardelevationprompt -eq $null)
{
outputanswer -answer "Behavior of the elevation prompt for standard users is not configured" -color Yellow
}
elseif ($standardelevationprompt -eq '0')
{
outputanswer -answer "Behavior of the elevation prompt for standard users is configured, but set to Automatically deny elevation requests" -color Yellow
}
elseif ($standardelevationprompt -eq '1')
{
outputanswer -answer "Behavior of the elevation prompt for standard users is configured set to Prompt for credentials on the secure desktop" -color Green
}
elseif ($standardelevationprompt -eq '3')
{
outputanswer -answer "Behavior of the elevation prompt for standard users is configured, but set to Prompt for credentials" -color Red
}
else
{
outputanswer -answer "Behavior of the elevation prompt for administrators is not configured" -color Red
}
#User Account Control: Detect application installations and prompt for elevation
$detectinstallelevate = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name EnableInstallerDetection -ErrorAction SilentlyContinue|Select-Object -ExpandProperty EnableInstallerDetection
if ($detectinstallelevate -eq $null)
{
outputanswer -answer "Detect application installations and prompt for elevation is not configured" -color Yellow
}
elseif ($detectinstallelevate -eq '1')
{
outputanswer -answer "Detect application installations and prompt for elevation is enabled" -color Green
}
else
{
outputanswer -answer "Detect application installations and prompt for elevation is disabled" -color Red
}
#User Account Control: Only elevate UIAccess applications that are installed in secure locations
$onlyelevateapps = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name EnableSecureUIAPaths -ErrorAction SilentlyContinue|Select-Object -ExpandProperty EnableSecureUIAPaths
if ($onlyelevateapps -eq $null)
{
outputanswer -answer "Only elevate UIAccess applications that are installed in secure locations is not configured" -color Yellow
}
elseif ($onlyelevateapps -eq '1')
{
outputanswer -answer "Only elevate UIAccess applications that are installed in secure locations is enabled" -color Green
}
else
{
outputanswer -answer "Only elevate UIAccess applications that are installed in secure locations is disabled" -color Red
}
#User Account Control: Run all administrators in Admin Approval Mode
$adminapprovalmode = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name EnableLUA -ErrorAction SilentlyContinue|Select-Object -ExpandProperty EnableLUA
if ($adminapprovalmode -eq $null)
{
outputanswer -answer "Run all administrators in Admin Approval Mode is not configured" -color Yellow
}
elseif ($adminapprovalmode -eq '1')
{
outputanswer -answer "Run all administrators in Admin Approval Mode is enabled" -color Green
}
else
{
outputanswer -answer "Run all administrators in Admin Approval Mode is disabled" -color Red
}
#User Account Control: Switch to the secure desktop when prompting for elevation
$promptonsecuredesktop = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name PromptOnSecureDesktop -ErrorAction SilentlyContinue|Select-Object -ExpandProperty PromptOnSecureDesktop
if ($promptonsecuredesktop -eq $null)
{
outputanswer -answer "Switch to the secure desktop when prompting for elevation is not configured" -color Yellow
}
elseif ($promptonsecuredesktop -eq '1')
{
outputanswer -answer "Switch to the secure desktop when prompting for elevation is enabled" -color Green
}
else
{
outputanswer -answer "Switch to the secure desktop when prompting for elevation is disabled" -color Red
}
# User Account Control: Virtualize file and registry write failures to per-user locations
$EnableVirtualization = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name EnableVirtualization -ErrorAction SilentlyContinue|Select-Object -ExpandProperty EnableVirtualization
if ($EnableVirtualization -eq $null)
{
outputanswer -answer "Virtualize file and registry write failures to per-user locations is not configured" -color Yellow
}
elseif ($EnableVirtualization -eq '1')
{
outputanswer -answer "Virtualize file and registry write failures to per-user locations is enabled" -color Green
}
else
{
outputanswer -answer "Virtualize file and registry write failures to per-user locations is disabled" -color Red
}
outputanswer -answer "EXPLOIT PROTECTION" -color White
# Use a common set of exploit protection settings (this has more settings need to research)
#$ExploitProtectionSettings = Get-ItemProperty -Path "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows Defender ExploitGuard\Exploit Protection" -Name ExploitProtectionSettings -ErrorAction SilentlyContinue|Select-Object -ExpandProperty ExploitProtectionSettings
#if ($ExploitProtectionSettings -eq $null)
#{
#outputanswer -answer "Use a common set of exploit protection settings is not configured" -color Yellow
#}
# elseif ($ExploitProtectionSettings -eq '1')
# {
# outputanswer -answer "Use a common set of exploit protection settings is enabled" -color Green
# }
# else
# {
# outputanswer -answer "Use a common set of exploit protection settings is disabled" -color Red
# }
# Prevent users from modifying settings
$DisallowExploitProtectionOverride = Get-ItemProperty -Path "Registry::HKLM\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\App and Browser protection" -Name DisallowExploitProtectionOverride -ErrorAction SilentlyContinue|Select-Object -ExpandProperty DisallowExploitProtectionOverride
if ($DisallowExploitProtectionOverride -eq $null)
{
outputanswer -answer "Prevent users from modifying settings is not configured" -color Yellow
}
elseif ($DisallowExploitProtectionOverride -eq '1')
{
outputanswer -answer "Prevent users from modifying settings is enabled" -color Green
}
else
{
outputanswer -answer "Prevent users from modifying settings is disabled" -color Red
}
# Turn off Data Execution Prevention for Explorer
$NoDataExecutionPrevention = Get-ItemProperty -Path "Registry::HKLM\Software\Policies\Microsoft\Windows\Explorer" -Name NoDataExecutionPrevention -ErrorAction SilentlyContinue|Select-Object -ExpandProperty NoDataExecutionPrevention
if ($NoDataExecutionPrevention -eq $null)
{
outputanswer -answer "Turn off Data Execution Prevention for Explorer is not configured" -color Yellow
}
elseif ($NoDataExecutionPrevention -eq '0')
{
outputanswer -answer "Turn off Data Execution Prevention for Explorer is disabled" -color Green
}
else
{
outputanswer -answer "Turn off Data Execution Prevention for Explorer is enabled" -color Red
}
# Enabled Structured Exception Handling Overwrite Protection (SEHOP)
$DisableExceptionChainValidation = Get-ItemProperty -Path "Registry::HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\kernel\" -Name DisableExceptionChainValidation -ErrorAction SilentlyContinue|Select-Object -ExpandProperty DisableExceptionChainValidation
if ($DisableExceptionChainValidation -eq $null)
{
outputanswer -answer "Enabled Structured Exception Handling Overwrite Protection (SEHOP) is not configured" -color Yellow
}
elseif ($DisableExceptionChainValidation -eq '0')
{
outputanswer -answer "Enabled Structured Exception Handling Overwrite Protection (SEHOP) is enabled" -color Green
}
else
{
outputanswer -answer "Enabled Structured Exception Handling Overwrite Protection (SEHOP) is disabled" -color Red
}
outputanswer -answer "LOCAL ADMINISTRATOR ACCOUNTS" -color White
# Accounts: Administrator account status
# This is apparently not a registry key, need to implement a check using another method later
#Apply UAC restrictions to local accounts on network logons
$LocalAccountTokenFilterPolicy = Get-ItemProperty -Path "Registry::HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\" -Name LocalAccountTokenFilterPolicy -ErrorAction SilentlyContinue|Select-Object -ExpandProperty LocalAccountTokenFilterPolicy
if ($LocalAccountTokenFilterPolicy -eq $null)
{
outputanswer -answer "Apply UAC restrictions to local accounts on network logons is not configured" -color Yellow
}
elseif ($LocalAccountTokenFilterPolicy -eq '0')
{
outputanswer -answer "Apply UAC restrictions to local accounts on network logons is enabled" -color Green
}
else
{
outputanswer -answer "Apply UAC restrictions to local accounts on network logons is disabled" -color Red
}
outputanswer -answer "MICROSOFT EDGE" -color White
#Allow Adobe Flash
$FlashPlayerEnabledLM = Get-ItemProperty -Path "Registry::HKLM\Software\Policies\Microsoft\MicrosoftEdge\Addons\" -Name FlashPlayerEnabled -ErrorAction SilentlyContinue|Select-Object -ExpandProperty FlashPlayerEnabled
$FlashPlayerEnabledUP = Get-ItemProperty -Path "Registry::HKCU\Software\Policies\Microsoft\MicrosoftEdge\Addons\" -Name FlashPlayerEnabled -ErrorAction SilentlyContinue|Select-Object -ExpandProperty FlashPlayerEnabled
if ($FlashPlayerEnabledLM -eq $null -and $FlashPlayerEnabledUP -eq $null)
{
outputanswer -answer "Flash Player is Not Configured" -color Yellow
}
if ($FlashPlayerEnabledLM -eq '0')
{
outputanswer -answer "Flash Player is disabled in Local Machine GP" -color Green
}
if ($FlashPlayerEnabledLM -eq '1')
{
outputanswer -answer "Flash Player is enabled in Local Machine GP" -color Red
}
if ($FlashPlayerEnabledUP -eq '0')
{
outputanswer -answer "Flash Player is disabled in User GP" -color Green
}
if ($FlashPlayerEnabledUP -eq '1')
{
outputanswer -answer "Flash Player is enabled in User GP" -color Red
}
#Allow Developer Tools
$AllowDeveloperToolsLM = Get-ItemProperty -Path "Registry::HKLM\Software\Policies\Microsoft\MicrosoftEdge\F12\" -Name AllowDeveloperTools -ErrorAction SilentlyContinue|Select-Object -ExpandProperty AllowDeveloperTools
$AllowDeveloperToolsUP = Get-ItemProperty -Path "Registry::HKCU\Software\Policies\Microsoft\MicrosoftEdge\F12\" -Name AllowDeveloperTools -ErrorAction SilentlyContinue|Select-Object -ExpandProperty AllowDeveloperTools
if ($AllowDeveloperToolsLM -eq $null -and $AllowDeveloperToolsUP -eq $null)
{
outputanswer -answer "Edge Developer Tools are Not Configured" -color Yellow
}
if ($AllowDeveloperToolsLM -eq '0')
{
outputanswer -answer "Edge Developer Tools are disabled in Local Machine GP" -color Green
}
if ($AllowDeveloperToolsLM -eq '1')
{
outputanswer -answer "Edge Developer Tools are enabled in Local Machine GP" -color Red
}
if ($AllowDeveloperToolsUP -eq '0')
{
outputanswer -answer "Edge Developer Tools are disabled in User GP" -color Green
}
if ($AllowDeveloperToolsUP -eq '1')
{
outputanswer -answer "Edge Developer Tools are enabled in User GP" -color Red
}
#Configure Do Not Track
$DoNotTrackLM = Get-ItemProperty -Path "Registry::HKLM\Software\Policies\Microsoft\MicrosoftEdge\Main\" -Name DoNotTrack -ErrorAction SilentlyContinue|Select-Object -ExpandProperty DoNotTrack
$DoNotTracksUP = Get-ItemProperty -Path "Registry::HKCU\Software\Policies\Microsoft\MicrosoftEdge\Main\" -Name DoNotTrack -ErrorAction SilentlyContinue|Select-Object -ExpandProperty DoNotTrack
if ($DoNotTrackLM -eq $null -and $DoNotTrackUP -eq $null)
{
outputanswer -answer "Edge Do Not Track is Not Configured" -color Yellow
}
if ($AllowDeveloperToolsLM -eq '0')
{
outputanswer -answer "Edge Do Not Track is disabled in Local Machine GP" -color Red
}
if ($AllowDeveloperToolsLM -eq '1')
{
outputanswer -answer "Edge Do Not Track is enabled in Local Machine GP" -color Green
}
if ($AllowDeveloperToolsUP -eq '0')
{
outputanswer -answer "Edge Do Not Track is disabled in User GP" -color Red
}
if ($AllowDeveloperToolsUP -eq '1')
{
outputanswer -answer "Edge Do Not Track is enabled in User GP" -color Green
}
#Configure Password Manager
$FormSuggestPasswordsLM = Get-ItemProperty -Path "Registry::HKLM\Software\Policies\Microsoft\MicrosoftEdge\Main\" -Name 'FormSuggest Passwords' -ErrorAction SilentlyContinue|Select-Object -ExpandProperty 'FormSuggest Passwords'
$FormSuggestPasswordsUP = Get-ItemProperty -Path "Registry::HKCU\Software\Policies\Microsoft\MicrosoftEdge\Main\" -Name 'FormSuggest Passwords' -ErrorAction SilentlyContinue|Select-Object -ExpandProperty 'FormSuggest Passwords'
if ($FormSuggestPasswordsLM -eq $null -and $FormSuggestPasswordsUP -eq $null)
{
outputanswer -answer "Edge Password Manager is Not Configured" -color Yellow
}
if ($FormSuggestPasswordsLM -eq 'no')
{
outputanswer -answer "Edge Password Manager is disabled in Local Machine GP" -color Red
}
if ($FormSuggestPasswordsLM -eq 'yes')
{
outputanswer -answer "Edge Password Manager is enabled in Local Machine GP" -color Green
}
if ($FormSuggestPasswordsUP -eq 'no')
{
outputanswer -answer "Edge Password Manager is disabled in User GP" -color Red
}
if ($FormSuggestPasswordsUP -eq 'yes')
{
outputanswer -answer "Edge Password Manager is enabled in User GP" -color Green
}
#Configure Pop-up Blocker
$AllowPopupsLM = Get-ItemProperty -Path "Registry::HKLM\Software\Policies\Microsoft\MicrosoftEdge\Main\" -Name AllowPopups -ErrorAction SilentlyContinue|Select-Object -ExpandProperty AllowPopups
$AllowPopupsUP = Get-ItemProperty -Path "Registry::HKCU\Software\Policies\Microsoft\MicrosoftEdge\Main\" -Name AllowPopups -ErrorAction SilentlyContinue|Select-Object -ExpandProperty AllowPopups
if ($AllowPopupsLM -eq $null -and $AllowPopupsUP -eq $null)
{
outputanswer -answer "Edge Pop-up Blocker is Not Configured" -color Yellow
}
if ($AllowPopupsLM -eq 'no')
{
outputanswer -answer "Edge Pop-up Blocker is disabled in Local Machine GP" -color Red
}
if ($AllowPopupsLM -eq 'yes')
{
outputanswer -answer "Edge Pop-up Blocker is enabled in Local Machine GP" -color Green
}
if ($AllowPopupsUP -eq 'no')
{
outputanswer -answer "Edge Pop-up Blocker is disabled in User GP" -color Red
}
if ($AllowPopupsUP -eq 'yes')
{
outputanswer -answer "Edge Pop-up Blocker is enabled in User GP" -color Green
}
$EnableSmartScreen = Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Windows\System\ -Name EnableSmartScreen -ErrorAction SilentlyContinue|Select-Object -ExpandProperty EnableSmartScreen
if ( $EnableSmartScreen -eq $null)
{
outputanswer -answer "Configure Windows Defender SmartScreen is not configured" -color Yellow