-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindows.ps1
More file actions
executable file
·2771 lines (2373 loc) · 151 KB
/
Windows.ps1
File metadata and controls
executable file
·2771 lines (2373 loc) · 151 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
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
###############################################################################
# Win10 / WinServer2016 Initial Setup Script
# Author: Disassembler <disassembler@dasm.cz>
# Version: v2.13, 2018-03-18
# Source: https://github.com/Disassembler0/Win10-Initial-Setup-Script
###############################################################################
$ScriptDirectory = Split-Path -Path $MyInvocation.MyCommand.Definition -Parent
try {
. ("$ScriptDirectory\Components\Console.ps1")
}
catch {
Write-Host "Error while loading PowerShell Console Scripts..."
}
Remove-Variable ScriptDirectory
# Default preset
$tweaks = @(
### Require administrator privileges ###
"RequireAdmin",
#"SetComputerName",
### Privacy Tweaks ###
"ConfigurePrivacySettings",
"DisableTelemetry", # "EnableTelemetry",
"DisableWiFiSense", # "EnableWiFiSense",
"DisableSmartScreen", # "EnableSmartScreen",
"DisableWebSearch", # "EnableWebSearch",
"DisableAppSuggestions", # "EnableAppSuggestions",
"DisableBackgroundApps", # "EnableBackgroundApps",
"DisableLockScreenSpotlight", # "EnableLockScreenSpotlight",
"DisableLocationTracking", # "EnableLocationTracking",
"DisableMapUpdates", # "EnableMapUpdates",
"DisableFeedback", # "EnableFeedback",
"DisableAdvertisingID", # "EnableAdvertisingID",
"DisableCortana", # "EnableCortana",
"DisableErrorReporting", # "EnableErrorReporting",
"SetP2PUpdateLocal", # "SetP2PUpdateInternet",
"DisableAutoLogger", # "EnableAutoLogger",
"DisableDiagTrack", # "EnableDiagTrack",
"DisableWAPPush", # "EnableWAPPush",
"DisableSyncSettings",
### Security Tweaks ###
# "SetUACLow", # "SetUACHigh",
# "EnableSharingMappedDrives", # "DisableSharingMappedDrives",
"DisableAdminShares", # "EnableAdminShares",
# "DisableSMB1", # "EnableSMB1",
"SetCurrentNetworkPrivate", # "SetCurrentNetworkPublic",
# "SetUnknownNetworksPrivate", # "SetUnknownNetworksPublic",
# "DisableNetDevicesAutoInst", # "EnableNetDevicesAutoInst",
# "EnableCtrldFolderAccess", # "DisableCtrldFolderAccess",
# "DisableFirewall", # "EnableFirewall",
# "DisableDefender", # "EnableDefender",
# "DisableDefenderCloud", # "EnableDefenderCloud",
"DisableDefenderReporting",
"EnableF8BootMenu", # "DisableF8BootMenu",
"DisableStartupSounds",
"SetDEPOptOut", # "SetDEPOptIn",
"DisableScriptHost", # "EnableScriptHost",
# "EnableMeltdownCompatFlag" # "DisableMeltdownCompatFlag",
### Service Tweaks ###
# "DisableUpdateMSRT", # "EnableUpdateMSRT",
# "DisableUpdateDriver", # "EnableUpdateDriver",
"DisableUpdateRestart", # "EnableUpdateRestart",
"DisableHomeGroups", # "EnableHomeGroups",
"DisableSharedExperiences", # "EnableSharedExperiences",
"DisableRemoteAssistance", # "EnableRemoteAssistance",
"EnableRemoteDesktop", # "DisableRemoteDesktop",
"DisableAutoplay", # "EnableAutoplay",
"DisableAutorun", # "EnableAutorun",
# "EnableStorageSense", # "DisableStorageSense",
# "DisableDefragmentation", # "EnableDefragmentation",
# "DisableSuperfetch", # "EnableSuperfetch",
# "DisableIndexing", # "EnableIndexing",
# "SetBIOSTimeUTC", # "SetBIOSTimeLocal",
# "EnableHibernationState", # "DisableHibernationState",
# "DisableSleepButton", # "EnableSleepButton",
# "DisableSleepTimeout", # "EnableSleepTimeout",
# "DisableFastStartup", # "EnableFastStartup",
"EnableAutomaticUpdates", # "DisableAutomaticUpdates",
### UI Tweaks ###
"SetSysTray",
"SetColorPrevalence",
"HideStoreAppsOnTaskbar",
"DisableActionCenter", # "EnableActionCenter",
"DisableLockScreen", # "EnableLockScreen",
# "DisableLockScreenRS1", # "EnableLockScreenRS1",
"ShowNetworkOnLockScreen", #"HideNetworkFromLockScreen",
"HideShutdownFromLockScreen", # "ShowShutdownOnLockScreen",
"SetLogonKeyboardLayout",
"DisableStickyKeys", # "EnableStickyKeys",
"ShowTaskManagerDetails" # "HideTaskManagerDetails",
"ShowFileOperationsDetails", # "HideFileOperationsDetails",
# "EnableFileDeleteConfirm", # "DisableFileDeleteConfirm",
"HideTaskbarSearchBox", # "ShowTaskbarSearchBox",
"HideTaskView", # "ShowTaskView",
"ShowSmallTaskbarIcons", # "ShowLargeTaskbarIcons",
"ShowTaskbarTitles", # "HideTaskbarTitles",
"HideTaskbarPeopleIcon", # "ShowTaskbarPeopleIcon",
"ShowTrayIcons", # "HideTrayIcons",
"DisableSearchAppInStore", # "EnableSearchAppInStore",
"DisableNewAppPrompt", # "EnableNewAppPrompt",
# "SetControlPanelViewIcons", # "SetControlPanelViewCategories",
"SetVisualFXPerformance", # "SetVisualFXAppearance",
# "AddENKeyboard", # "RemoveENKeyboard",
# "EnableNumlock", # "DisableNumlock",
### Explorer UI Tweaks ###
"ShowKnownExtensions", # "HideKnownExtensions",
"ShowHiddenFiles", # "HideHiddenFiles",
"ShowPathInTitleBar", # "HidePathInTitleBar",
"HideSyncNotifications" # "ShowSyncNotifications",
"HideRecentShortcuts", # "ShowRecentShortcuts",
"SetExplorerThisPC", # "SetExplorerQuickAccess",
"ShowThisPCOnDesktop", # "HideThisPCFromDesktop",
# "ShowUserFolderOnDesktop", # "HideUserFolderFromDesktop",
"HideDesktopFromThisPC", # "ShowDesktopInThisPC",
# "HideDesktopFromExplorer", # "ShowDesktopInExplorer",
"HideDocumentsFromThisPC", # "ShowDocumentsInThisPC",
# "HideDocumentsFromExplorer", # "ShowDocumentsInExplorer",
"HideDownloadsFromThisPC", # "ShowDownloadsInThisPC",
# "HideDownloadsFromExplorer", # "ShowDownloadsInExplorer",
"HideMusicFromThisPC", # "ShowMusicInThisPC",
# "HideMusicFromExplorer", # "ShowMusicInExplorer",
"HidePicturesFromThisPC", # "ShowPicturesInThisPC",
# "HidePicturesFromExplorer", # "ShowPicturesInExplorer",
"HideVideosFromThisPC", # "ShowVideosInThisPC",
# "HideVideosFromExplorer", # "ShowVideosInExplorer",
"Hide3DObjectsFromThisPC", # "Show3DObjectsInThisPC",
# "Hide3DObjectsFromExplorer", # "Show3DObjectsInExplorer",
# "DisableThumbnails", # "EnableThumbnails",
"DisableThumbsDB", # "EnableThumbsDB",
"DisableConfirmDeleteRecycleBin",
"EnableLoginCustomBackground",
### Application Tweaks ###
"DisableOneDrive", # "EnableOneDrive",
"UninstallOneDrive", # "InstallOneDrive",
"UninstallMsftBloat", # "InstallMsftBloat",
"UninstallThirdPartyBloat", # "InstallThirdPartyBloat",
"RemoveProvisionedBloat",
# "UninstallWindowsStore", # "InstallWindowsStore",
"DisableXboxFeatures", # "EnableXboxFeatures",
"DisableAdobeFlash", # "EnableAdobeFlash",
# "UninstallMediaPlayer", # "InstallMediaPlayer",
# "UninstallWorkFolders", # "InstallWorkFolders",
# "InstallLinuxSubsystem", # "UninstallLinuxSubsystem",
# "InstallHyperV", # "UninstallHyperV",
"SetPowershellScriptAction",
"SetPhotoViewerAssociation", # "UnsetPhotoViewerAssociation",
"AddPhotoViewerOpenWith", # "RemovePhotoViewerOpenWith",
# "UninstallPDFPrinter", # "InstallPDFPrinter",
#"UninstallXPSPrinter", # "InstallXPSPrinter",
"RemoveFaxPrinter", # "AddFaxPrinter",
"ConfigInternetExplorer",
"ConfigAccessibility",
### Server Specific Tweaks ###
# "HideServerManagerOnLogin", # "ShowServerManagerOnLogin",
# "DisableShutdownTracker", # "EnableShutdownTracker",
# "DisablePasswordPolicy", # "EnablePasswordPolicy",
# "DisableCtrlAltDelLogin", # "EnableCtrlAltDelLogin",
# "DisableSMLogonStart",
# "DisableIEEnhancedSecurity", # "EnableIEEnhancedSecurity",
#"DisableHibernation", # "EnableHibernation",
### Unpinning ###
# "UnpinStartMenuTiles",
# "UnpinTaskbarIcons",
"ConfigurePowershellConsole",
"SetDiskCleanup",
"SetUserTweaks",
### Auxiliary Functions ###
"WaitForKey",
"Restart"
)
###############################################################################
### Identity #
###############################################################################
# Set Computer Name
Function SetComputerName {
Write-Output "Configuring System..."
(Get-WmiObject Win32_ComputerSystem).Rename("MADMW001") | Out-Null
## Set DisplayName for my account. Use only if you are not using a Microsoft Account
#$myIdentity=[System.Security.Principal.WindowsIdentity]::GetCurrent()
#$user = Get-WmiObject Win32_UserAccount | Where {$_.Caption -eq $myIdentity.Name}
#$user.FullName = "Jay Harris
#$user.Put() | Out-Null
#Remove-Variable user
#Remove-Variable myIdentity
# Enable Developer Mode
#SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" "AllowDevelopmentWithoutDevLicense" 1
# Bash on Windows
#Enable-WindowsOptionalFeature -Online -All -FeatureName "Microsoft-Windows-Subsystem-Linux" -NoRestart -WarningAction SilentlyContinue | Out-Null
}
###############################################################################
### Privacy Tweaks #
###############################################################################
Function ConfigurePrivacySettings {
Write-Output "Configuring Privacy..."
# General: Opt-out from websites from accessing language list: Opt-in: 0, Opt-out 1
SetRegistryKey "HKCU:\Control Panel\International\User Profile" "HttpAcceptLanguageOptOut" "DWord" 1
# General: Disable SmartGlass: Enable: 1, Disable: 0
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\SmartGlass" "UserAuthPolicy" "DWord" 0
# General: Disable SmartGlass over BlueTooth: Enable: 1, Disable: 0
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\SmartGlass" "BluetoothPolicy" "DWord" 0
# Camera: Don't let apps use camera: Allow, Deny
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{E5323777-F976-4f5b-9B55-B94699C46E44}" "Value" "String" "Deny"
# Microphone: Don't let apps use microphone: Allow, Deny
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{2EEF81BE-33FA-4800-9670-1CD474972C3F}" "Value" "String" "Deny"
# Notifications: Don't let apps access notifications: Allow, Deny
# Build 1511
# SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{21157C1F-2651-4CC1-90CA-1F28B02263F6}" "Value" "String" "Deny"
# Build 1607, 1709
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{52079E78-A92B-413F-B213-E8FE35712E72}" "Value" "String" "Deny"
# Account Info: Don't let apps access name, picture, and other account info: Allow, Deny
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{C1D23ACC-752B-43E5-8448-8D0E519CD6D6}" "Value" "String" "Deny"
# Contacts: Don't let apps access contacts: Allow, Deny
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{7D7E8402-7C54-4821-A34E-AEEFD62DED93}" "Value" "String" "Deny"
# Calendar: Don't let apps access calendar: Allow, Deny
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{D89823BA-7180-4B81-B50C-7E471E6121A3}" "Value" "String" "Deny"
# Call History: Don't let apps access call history: Allow, Deny
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{8BC668CF-7728-45BD-93F8-CF2B3B41D7AB}" "Value" "String" "Deny"
# Email: Don't let apps read and send email: Allow, Deny
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{9231CB4C-BF57-4AF3-8C55-FDA7BFCC04C5}" "Value" "String" "Deny"
# Messaging: Don't let apps read or send messages (text or MMS): Allow, Deny
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{992AFA70-6F47-4148-B3E9-3003349C1548}" "Value" "String" "Deny"
# Radios: Don't let apps control radios (like Bluetooth): Allow, Deny
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\{A8804298-2D5F-42E3-9531-9C8C39EB29CE}" "Value" "String" "Deny"
# Other Devices: Don't let apps share and sync with non-explicitly-paired wireless devices over uPnP: Allow, Deny
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeviceAccess\Global\LooselyCoupled" "Value" "String" "Deny"
}
# Disable Telemetry
# Note: This tweak may cause Enterprise edition to stop receiving Windows updates.
# Windows Update control panel will then show message "Your device is at risk because it's out of date and missing important security and quality updates. Let's get you back on track so Windows can run more securely. Select this button to get going".
# In such case, enable telemetry, run Windows update and then disable telemetry again. See also https://github.com/Disassembler0/Win10-Initial-Setup-Script/issues/57
Function DisableTelemetry {
Write-Output "Disabling Telemetry..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection" "AllowTelemetry" "DWord" 0
SetRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" "AllowTelemetry" "DWord" 0
SetRegistryKey "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection" "AllowTelemetry" "DWord" 0
# Disable key logging & transmission to Microsoft: Enable: 1, Disable: 0
# Disabled when Telemetry is set to Basic
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Input\TIPC" "Enabled" "DWord" 0
Disable-ScheduledTask -TaskName "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" | Out-Null
Disable-ScheduledTask -TaskName "Microsoft\Windows\Application Experience\ProgramDataUpdater" | Out-Null
Disable-ScheduledTask -TaskName "Microsoft\Windows\Autochk\Proxy" | Out-Null
Disable-ScheduledTask -TaskName "Microsoft\Windows\Customer Experience Improvement Program\Consolidator" | Out-Null
Disable-ScheduledTask -TaskName "Microsoft\Windows\Customer Experience Improvement Program\UsbCeip" | Out-Null
Disable-ScheduledTask -TaskName "Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector" | Out-Null
}
# Enable Telemetry
Function EnableTelemetry {
Write-Output "Enabling Telemetry..."
# Feedback: Telemetry: Send Diagnostic and usage data: Basic: 1, Enhanced: 2, Full: 3
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection" "AllowTelemetry" "DWord" 1
SetRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" "AllowTelemetry" "DWord" 1
SetRegistryKey "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection" "AllowTelemetry" "DWord" 1
Enable-ScheduledTask -TaskName "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" | Out-Null
Enable-ScheduledTask -TaskName "Microsoft\Windows\Application Experience\ProgramDataUpdater" | Out-Null
Enable-ScheduledTask -TaskName "Microsoft\Windows\Autochk\Proxy" | Out-Null
Enable-ScheduledTask -TaskName "Microsoft\Windows\Customer Experience Improvement Program\Consolidator" | Out-Null
Enable-ScheduledTask -TaskName "Microsoft\Windows\Customer Experience Improvement Program\UsbCeip" | Out-Null
Enable-ScheduledTask -TaskName "Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector" | Out-Null
}
# Disable automatically syncing settings with other Windows 10 devices
Function DisableSyncSettings {
Write-Output "Disabling syncing settings..."
# Theme
SetRegistryKey "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Personalization" "Enabled" "DWord" 0
# Internet Explorer
SetRegistryKey "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\BrowserSettings" "Enabled" "DWord" 0
# Passwords
SetRegistryKey "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Credentials" "Enabled" "DWord" 0
# Language
SetRegistryKey "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Language" "Enabled" "DWord" 0
# Accessibility / Ease of Access
SetRegistryKey "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Accessibility" "Enabled" "DWord" 0
# Other Windows Settings
SetRegistryKey "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Windows" "Enabled" "DWord" 0
}
# Disable Wi-Fi Sense
Function DisableWiFiSense {
Write-Output "Disabling Wi-Fi Sense..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" "Value" "DWord" 0
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots" "Value" "DWord" 0
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" "AutoConnectAllowedOEM" "DWord" 0
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" "WiFISenseAllowed" "DWord" 0
}
# Enable Wi-Fi Sense
Function EnableWiFiSense {
Write-Output "Enabling Wi-Fi Sense..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" "Value" "DWord" 1
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots" "Value" "DWord" 1
DeleteRegistryKey "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" "AutoConnectAllowedOEM"
DeleteRegistryKey "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" "WiFISenseAllowed"
}
# Disable SmartScreen Filter
Function DisableSmartScreen {
Write-Output "Disabling SmartScreen Filter..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" "SmartScreenEnabled" "String" "Off"
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost" "EnableWebContentEvaluation" "DWord" 0
$edge = (Get-AppxPackage -AllUsers "Microsoft.MicrosoftEdge").PackageFamilyName
SetRegistryKey "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" "EnabledV9" "DWord" 0
SetRegistryKey "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" "PreventOverride" "DWord" 0
}
# Enable SmartScreen Filter
Function EnableSmartScreen {
Write-Output "Enabling SmartScreen Filter..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" "SmartScreenEnabled" "String" "RequireAdmin"
DeleteRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost" "EnableWebContentEvaluation"
$edge = (Get-AppxPackage -AllUsers "Microsoft.MicrosoftEdge").PackageFamilyName
DeleteRegistryKey "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" "EnabledV9"
DeleteRegistryKey "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" "PreventOverride"
}
# Disable Web Search in Start Menu
Function DisableWebSearch {
Write-Output "Disabling Bing Search in Start Menu..."
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" "BingSearchEnabled" "DWord" 0
SetRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" "DisableWebSearch" "DWord" 1
}
# Enable Web Search in Start Menu
Function EnableWebSearch {
Write-Output "Enabling Bing Search in Start Menu..."
DeleteRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" "BingSearchEnabled"
DeleteRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" "DisableWebSearch"
}
# Disable Application suggestions and automatic installation
Function DisableAppSuggestions {
Write-Output "Disabling Application suggestions..."
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "ContentDeliveryAllowed" "DWord" 0
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "OemPreInstalledAppsEnabled" "DWord" 0
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "PreInstalledAppsEnabled" "DWord" 0
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "PreInstalledAppsEverEnabled" "DWord" 0
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "SilentInstalledAppsEnabled" "DWord" 0
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "SubscribedContent-338389Enabled" "DWord" 0
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "SystemPaneSuggestionsEnabled" "DWord" 0
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "SubscribedContent-338388Enabled" "DWord" 0
SetRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" "DisableWindowsConsumerFeatures" "DWord" 1
}
# Enable Application suggestions and automatic installation
Function EnableAppSuggestions {
Write-Output "Enabling Application suggestions..."
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "ContentDeliveryAllowed" "DWord" 1
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "OemPreInstalledAppsEnabled" "DWord" 1
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "PreInstalledAppsEnabled" "DWord" 1
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "PreInstalledAppsEverEnabled" "DWord" 1
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "SilentInstalledAppsEnabled" "DWord" 1
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "SubscribedContent-338389Enabled" "DWord" 1
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "SystemPaneSuggestionsEnabled" "DWord" 1
DeleteRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "SubscribedContent-338388Enabled"
DeleteRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" "DisableWindowsConsumerFeatures"
}
# Disable Background application access - ie. if apps can download or update when they aren't used - Cortana is excluded as its inclusion breaks start menu search
Function DisableBackgroundApps {
Write-Output "Disabling Background application access..."
Get-ChildItem -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications" -Exclude "Microsoft.Windows.Cortana*" | ForEach {
SetRegistryKey $_.PsPath "Disabled" "DWord" 1
SetRegistryKey $_.PsPath "DisabledByUser" "DWord" 1
}
}
# Enable Background application access
Function EnableBackgroundApps {
Write-Output "Enabling Background application access..."
Get-ChildItem -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications" | ForEach {
DeleteRegistryKey $_.PsPath "Disabled"
DeleteRegistryKey $_.PsPath "DisabledByUser"
}
}
# Disable Lock screen Spotlight - New backgrounds, tips, advertisements etc.
Function DisableLockScreenSpotlight {
Write-Output "Disabling Lock screen spotlight..."
SetRegistryKey "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "RotatingLockScreenEnabled" "DWord" 0
SetRegistryKey "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "RotatingLockScreenOverlayEnabled" "DWord" 0
SetRegistryKey "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "SubscribedContent-338387Enabled" "DWord" 0
}
# Enable Lock screen Spotlight
Function EnableLockScreenSpotlight {
Write-Output "Disabling Lock screen spotlight..."
SetRegistryKey "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "RotatingLockScreenEnabled" "DWord" 1
SetRegistryKey "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "RotatingLockScreenOverlayEnabled" "DWord" 1
DeleteRegistryKey "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" "SubscribedContent-338387Enabled"
}
# Disable Location Tracking
Function DisableLocationTracking {
Write-Output "Disabling Location Tracking..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}" "SensorPermissionState" "DWord" 0
SetRegistryKey "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration" "Status" "DWord" 0
}
# Enable Location Tracking
Function EnableLocationTracking {
Write-Output "Enabling Location Tracking..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}" "SensorPermissionState" "DWord" 1
SetRegistryKey "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration" "Status" "DWord" 1
}
# Disable automatic Maps updates
Function DisableMapUpdates {
Write-Output "Disabling automatic Maps updates..."
SetRegistryKey "HKLM:\SYSTEM\Maps" "AutoUpdateEnabled" "DWord" 0
}
# Enable automatic Maps updates
Function EnableMapUpdates {
Write-Output "Enable automatic Maps updates..."
DeleteRegistryKey "HKLM:\SYSTEM\Maps" "AutoUpdateEnabled"
}
# Disable Feedback
Function DisableFeedback {
Write-Output "Disabling Feedback..."
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" "NumberOfSIUFInPeriod" "DWord" 0
Disable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClient" | Out-Null
Disable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClientOnScenarioDownload" | Out-Null
}
# Enable Feedback
Function EnableFeedback {
Write-Output "Enabling Feedback..."
DeleteRegistryKey "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" "NumberOfSIUFInPeriod"
Enable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClient" | Out-Null
Enable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClientOnScenarioDownload" | Out-Null
}
# Disable Advertising ID
Function DisableAdvertisingID {
Write-Output "Disabling Advertising ID..."
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo" "Enabled" "DWord" 0
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy" "TailoredExperiencesWithDiagnosticDataEnabled" "DWord" 0
}
# Enable Advertising ID
Function EnableAdvertisingID {
Write-Output "Enabling Advertising ID..."
DeleteRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo" "Enabled"
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy" "TailoredExperiencesWithDiagnosticDataEnabled" "DWord" 2
}
# Disable Cortana
Function DisableCortana {
Write-Output "Disabling Cortana..."
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" "AcceptedPrivacyPolicy" "DWord" 0
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\InputPersonalization" "RestrictImplicitTextCollection" "DWord" 1
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\InputPersonalization" "RestrictImplicitInkCollection" "DWord" 1
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" "HarvestContacts" "DWord" 0
SetRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" "AllowCortana" "DWord" 0
}
# Enable Cortana
Function EnableCortana {
Write-Output "Enabling Cortana..."
DeleteRegistryKey "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" "AcceptedPrivacyPolicy"
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\InputPersonalization" "RestrictImplicitTextCollection" "DWord" 0
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\InputPersonalization" "RestrictImplicitInkCollection" "DWord" 0
DeleteRegistryKey "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" "HarvestContacts"
DeleteRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" "AllowCortana"
}
# Disable Error reporting
Function DisableErrorReporting {
Write-Output "Disabling Error reporting..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" "Disabled" "DWord" 1
Disable-ScheduledTask -TaskName "Microsoft\Windows\Windows Error Reporting\QueueReporting" | Out-Null
}
# Enable Error reporting
Function EnableErrorReporting {
Write-Output "Enabling Error reporting..."
DeleteRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" "Disabled"
Enable-ScheduledTask -TaskName "Microsoft\Windows\Windows Error Reporting\QueueReporting" | Out-Null
}
# Remove AutoLogger file and restrict directory
Function DisableAutoLogger {
Write-Output "Removing AutoLogger file and restricting directory..."
$autoLoggerDir = "$env:PROGRAMDATA\Microsoft\Diagnosis\ETLLogs\AutoLogger"
If (Test-Path "$autoLoggerDir\AutoLogger-Diagtrack-Listener.etl") {
Remove-Item -Path "$autoLoggerDir\AutoLogger-Diagtrack-Listener.etl" -ErrorAction SilentlyContinue
}
icacls $autoLoggerDir /deny SYSTEM:`(OI`)`(CI`)F | Out-Null
}
# Unrestrict AutoLogger directory
Function EnableAutoLogger {
Write-Output "Unrestricting AutoLogger directory..."
$autoLoggerDir = "$env:PROGRAMDATA\Microsoft\Diagnosis\ETLLogs\AutoLogger"
icacls $autoLoggerDir /grant:r SYSTEM:`(OI`)`(CI`)F | Out-Null
}
# Stop and disable Diagnostics Tracking Service
Function DisableDiagTrack {
Write-Output "Stopping and disabling Diagnostics Tracking Service..."
Stop-Service "DiagTrack" -WarningAction SilentlyContinue
Set-Service "DiagTrack" -StartupType Disabled
}
# Enable and start Diagnostics Tracking Service
Function EnableDiagTrack {
Write-Output "Enabling and starting Diagnostics Tracking Service..."
Set-Service "DiagTrack" -StartupType Automatic
Start-Service "DiagTrack" -WarningAction SilentlyContinue
}
# Stop and disable WAP Push Service
Function DisableWAPPush {
Write-Output "Stopping and disabling WAP Push Service..."
Stop-Service "dmwappushservice" -WarningAction SilentlyContinue
Set-Service "dmwappushservice" -StartupType Disabled
}
# Enable and start WAP Push Service
Function EnableWAPPush {
Write-Output "Enabling and starting WAP Push Service..."
Set-Service "dmwappushservice" -StartupType Automatic
Start-Service "dmwappushservice" -WarningAction SilentlyContinue
SetRegistryKey "HKLM:\SYSTEM\CurrentControlSet\Services\dmwappushservice" "DelayedAutoStart" "DWord" 1
}
###############################################################################
### Security Tweaks #
###############################################################################
# Lower UAC level (disabling it completely would break apps)
Function SetUACLow {
Write-Output "Lowering UAC level..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" "ConsentPromptBehaviorAdmin" "DWord" 0
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" "PromptOnSecureDesktop" "DWord" 0
}
# Raise UAC level
Function SetUACHigh {
Write-Output "Raising UAC level..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" "ConsentPromptBehaviorAdmin" "DWord" 5
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" "PromptOnSecureDesktop" "DWord" 1
}
# Set Data Execution Prevention (DEP) policy to OptOut
Function SetDEPOptOut {
Write-Output "Setting Data Execution Prevention (DEP) policy to OptOut..."
bcdedit /set `{current`} nx OptOut | Out-Null
}
# Set Data Execution Prevention (DEP) policy to OptIn
Function SetDEPOptIn {
Write-Output "Setting Data Execution Prevention (DEP) policy to OptIn..."
bcdedit /set `{current`} nx OptIn | Out-Null
}
# Disable Windows Script Host (execution of *.vbs scripts and alike)
Function DisableScriptHost {
Write-Output "Disabling Windows Script Host..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" "Enabled" "DWord" 0
}
# Enable Windows Script Host
Function EnableScriptHost {
Write-Output "Enabling Windows Script Host..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" "Enabled" "DWord" 1
}
# Enable Meltdown (CVE-2017-5754) compatibility flag - Required for January 2018 and all subsequent Windows updates
# This flag is normally automatically enabled by compatible antivirus software (such as Windows Defender).
# Use the tweak only if you have confirmed that your AV is compatible but unable to set the flag automatically or if you don't use any AV at all.
# See https://support.microsoft.com/en-us/help/4072699/january-3-2018-windows-security-updates-and-antivirus-software for details.
Function EnableMeltdownCompatFlag {
Write-Output "Enabling Meltdown (CVE-2017-5754) compatibility flag..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat" "cadca5fe-87d3-4b96-b7fb-a231484277cc" "DWord" 0
}
# Disable Meltdown (CVE-2017-5754) compatibility flag
Function DisableMeltdownCompatFlag {
Write-Output "Disabling Meltdown (CVE-2017-5754) compatibility flag..."
DeleteRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat" "cadca5fe-87d3-4b96-b7fb-a231484277cc"
}
# Enable sharing mapped drives between users
Function EnableSharingMappedDrives {
Write-Output "Enabling sharing mapped drives between users..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" "EnableLinkedConnections" "DWord" 1
}
# Disable sharing mapped drives between users
Function DisableSharingMappedDrives {
Write-Output "Disabling sharing mapped drives between users..."
DeleteRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" "EnableLinkedConnections"
}
# Disable implicit administrative shares
Function DisableAdminShares {
Write-Output "Disabling implicit administrative shares..."
SetRegistryKey "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" "AutoShareWks" "DWord" 0
}
# Enable implicit administrative shares
Function EnableAdminShares {
Write-Output "Enabling implicit administrative shares..."
DeleteRegistryKey "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" "AutoShareWks"
}
# Disable obsolete SMB 1.0 protocol - Disabled by default since 1709
Function DisableSMB1 {
Write-Output "Disabling SMB 1.0 protocol..."
Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
}
# Enable obsolete SMB 1.0 protocol - Disabled by default since 1709
Function EnableSMB1 {
Write-Output "Enabling SMB 1.0 protocol..."
Set-SmbServerConfiguration -EnableSMB1Protocol $true -Force
}
# Set current network profile to private (allow file sharing, device discovery, etc.)
Function SetCurrentNetworkPrivate {
Write-Output "Setting current network profile to private..."
Set-NetConnectionProfile -NetworkCategory Private
}
# Set current network profile to public (deny file sharing, device discovery, etc.)
Function SetCurrentNetworkPublic {
Write-Output "Setting current network profile to public..."
Set-NetConnectionProfile -NetworkCategory Public
}
# Set unknown networks profile to private (allow file sharing, device discovery, etc.)
Function SetUnknownNetworksPrivate {
Write-Output "Setting unknown networks profile to private..."
SetRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\010103000F0000F0010000000F0000F0C967A3643C3AD745950DA7859209176EF5B87C875FA20DF21951640E807D7C24" "Category" "DWord" 1
}
# Set unknown networks profile to public (deny file sharing, device discovery, etc.)
Function SetUnknownNetworksPublic {
Write-Output "Setting unknown networks profile to public..."
DeleteRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\010103000F0000F0010000000F0000F0C967A3643C3AD745950DA7859209176EF5B87C875FA20DF21951640E807D7C24" "Category"
}
# Disable automatic installation of network devices
Function DisableNetDevicesAutoInst {
Write-Output "Disabling automatic installation of network devices..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private" "AutoSetup" "DWord" 0
}
# Enable automatic installation of network devices
Function EnableNetDevicesAutoInst {
Write-Output "Enabling automatic installation of network devices..."
DeleteRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private" "AutoSetup"
}
###############################################################################
### Windows Defender #
###############################################################################
# Enable Controlled Folder Access (Defender Exploit Guard feature) - Not applicable to Server
Function EnableCtrldFolderAccess {
Write-Output "Enabling Controlled Folder Access..."
Set-MpPreference -EnableControlledFolderAccess Enabled
}
# Disable Controlled Folder Access (Defender Exploit Guard feature) - Not applicable to Server
Function DisableCtrldFolderAccess {
Write-Output "Disabling Controlled Folder Access..."
Set-MpPreference -EnableControlledFolderAccess Disabled
}
# Enable Windows Defender
Function EnableDefender {
Write-Output "Enabling Windows Defender..."
DeleteRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" "DisableAntiSpyware"
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "SecurityHealth" -Type ExpandString -Value "`"%ProgramFiles%\Windows Defender\MSASCuiL.exe`""
}
# Disable Windows Defender
Function DisableDefender {
Write-Output "Disabling Windows Defender..."
SetRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" "DisableAntiSpyware" "DWord" 1
DeleteRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" "SecurityHealth"
}
# Disable Windows Defender Cloud
Function DisableDefenderCloud {
Write-Output "Disabling Windows Defender Cloud..."
SetRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" "SpynetReporting" "DWord" 0
SetRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" "SubmitSamplesConsent" "DWord" 2
}
# Enable Windows Defender Cloud
Function EnableDefenderCloud {
Write-Output "Enabling Windows Defender Cloud..."
DeleteRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" "SpynetReporting"
DeleteRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" "SubmitSamplesConsent"
}
Function DisableDefenderReporting {
Write-Output "Disabling Windows Defender Reporting..."
# Disable Cloud-Based Protection: Enabled Advanced: 2, Enabled Basic: 1, Disabled: 0
Set-MpPreference -MAPSReporting 0
# Disable automatic sample submission: Prompt: 0, Auto Send Safe: 1, Never: 2, Auto Send All: 3
Set-MpPreference -SubmitSamplesConsent 2
}
###############################################################################
### Windows Firewall #
###############################################################################
# Disable Firewall
Function DisableFirewall {
Write-Output "Disabling Firewall..."
SetRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfile" "EnableFirewall" "DWord" 0
}
# Enable Firewall
Function EnableFirewall {
Write-Output "Enabling Firewall..."
DeleteRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfile" "EnableFirewall"
}
###############################################################################
### Devices, Power, and Startup #
###############################################################################
# Enable F8 boot menu options
Function EnableF8BootMenu {
Write-Output "Enabling F8 boot menu options..."
bcdedit /set `{current`} bootmenupolicy Legacy | Out-Null
}
# Disable F8 boot menu options
Function DisableF8BootMenu {
Write-Output "Disabling F8 boot menu options..."
bcdedit /set `{current`} bootmenupolicy Standard | Out-Null
}
Function DisableStartupSounds {
Write-Output "Disabling startup Sound..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" "DisableStartupSound" "DWord" 1
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\BootAnimation" "DisableStartupSound" "DWord" 1
}
# Power: Disable Hibernation
Function DisableHibernation {
Write-Output "Disabling startup Sound..."
powercfg /hibernate off
}
# Power: Enable Hibernation
Function EnableHibernation {
# Power: Disable Hibernation
powercfg /hibernate on
}
###############################################################################
### Windows Update #
###############################################################################
# Enable Automatic Updates
Function EnableAutomaticUpdates {
Write-Output "Enabling automated updates..."
SetRegistryKey "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" "NoAutoUpdate" "DWord" 0
# Configure to Auto-Download but not Install: NotConfigured: 0, Disabled: 1, NotifyBeforeDownload: 2, NotifyBeforeInstall: 3, ScheduledInstall: 4
SetRegistryKey "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" "AUOptions" "DWord" 3
# Include Recommended Updates
SetRegistryKey "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" "IncludeRecommendedUpdates" "DWord" 1
# Opt-In to Microsoft Update
$MU = New-Object -ComObject Microsoft.Update.ServiceManager -Strict
$MU.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"") | Out-Null
Remove-Variable MU
}
# Disable Automatic Updates
Function DisableAutomaticUpdates {
Write-Output "Disabling automated updates..."
SetRegistryKey "HKLM:\Software\Policies\Microsoft\Windows\WindowsUpdate\AU" "NoAutoUpdate" "DWord" 1
}
# Disable offering of Malicious Software Removal Tool through Windows Update
Function DisableUpdateMSRT {
Write-Output "Disabling Malicious Software Removal Tool offering..."
SetRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\MRT" "DontOfferThroughWUAU" "DWord" 1
}
# Enable offering of Malicious Software Removal Tool through Windows Update
Function EnableUpdateMSRT {
Write-Output "Enabling Malicious Software Removal Tool offering..."
DeleteRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\MRT" "DontOfferThroughWUAU"
}
# Disable offering of drivers through Windows Update
Function DisableUpdateDriver {
Write-Output "Disabling driver offering through Windows Update..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching" "SearchOrderConfig" "DWord" 0
SetRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" "ExcludeWUDriversInQualityUpdate" "DWord" 1
}
# Enable offering of drivers through Windows Update
Function EnableUpdateDriver {
Write-Output "Enabling driver offering through Windows Update..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching" "SearchOrderConfig" "DWord" 1
DeleteRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" "ExcludeWUDriversInQualityUpdate"
}
# Disable Windows Update automatic restart
Function DisableUpdateRestart {
Write-Output "Disabling Windows Update automatic restart..."
SetRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" "NoAutoRebootWithLoggedOnUsers" "DWord" 1
SetRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" "AUPowerManagement" "DWord" 0
}
# Enable Windows Update automatic restart
Function EnableUpdateRestart {
Write-Output "Enabling Windows Update automatic restart..."
DeleteRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" "NoAutoRebootWithLoggedOnUsers"
DeleteRegistryKey "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" "AUPowerManagement"
}
# Restrict Windows Update P2P only to local network
Function SetP2PUpdateLocal {
Write-Output "Restricting Windows Update P2P only to local network..."
# Delivery Optimization:
# Download from 0: Http Only [Disable], 1: Peering on LAN, 2: Peering on AD / Domain, 3: Peering on Internet, 99: No peering, 100: Bypass & use BITS
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" "DODownloadMode" "DWord" 1
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization" "SystemSettingsDownloadMode" "DWord" 3
}
# Unrestrict Windows Update P2P
Function SetP2PUpdateInternet {
Write-Output "Unrestricting Windows Update P2P to internet..."
DeleteRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" "DODownloadMode"
DeleteRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization" "SystemSettingsDownloadMode"
}
###############################################################################
### Service Tweaks #
###############################################################################
# Stop and disable Home Groups services - Not applicable to Server
Function DisableHomeGroups {
Write-Output "Stopping and disabling Home Groups services..."
Stop-Service "HomeGroupListener" -WarningAction SilentlyContinue
Set-Service "HomeGroupListener" -StartupType Disabled
Stop-Service "HomeGroupProvider" -WarningAction SilentlyContinue
Set-Service "HomeGroupProvider" -StartupType Disabled
}
# Enable and start Home Groups services - Not applicable to Server
Function EnableHomeGroups {
Write-Output "Starting and enabling Home Groups services..."
Set-Service "HomeGroupListener" -StartupType Manual
Set-Service "HomeGroupProvider" -StartupType Manual
Start-Service "HomeGroupProvider" -WarningAction SilentlyContinue
}
# Disable Shared Experiences - Not applicable to Server
Function DisableSharedExperiences {
Write-Output "Disabling Shared Experiences..."
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\CDP" "RomeSdkChannelUserAuthzPolicy" "DWord" 0
}
# Enable Shared Experiences - Not applicable to Server
Function EnableSharedExperiences {
Write-Output "Enabling Shared Experiences..."
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\CDP" "RomeSdkChannelUserAuthzPolicy" "DWord" 1
}
# Disable Remote Assistance - Not applicable to Server (unless Remote Assistance is explicitly installed)
Function DisableRemoteAssistance {
Write-Output "Disabling Remote Assistance..."
SetRegistryKey "HKLM:\SYSTEM\CurrentControlSet\Control\Remote Assistance" "fAllowToGetHelp" "DWord" 0
}
# Enable Remote Assistance - Not applicable to Server (unless Remote Assistance is explicitly installed)
Function EnableRemoteAssistance {
Write-Output "Enabling Remote Assistance..."
SetRegistryKey "HKLM:\SYSTEM\CurrentControlSet\Control\Remote Assistance" "fAllowToGetHelp" "DWord" 1
}
# Enable Remote Desktop w/o Network Level Authentication
Function EnableRemoteDesktop {
Write-Output "Enabling Remote Desktop w/o Network Level Authentication..."
SetRegistryKey "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" "fDenyTSConnections" "DWord" 0
SetRegistryKey "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" "UserAuthentication" "DWord" 0
}
# Disable Remote Desktop
Function DisableRemoteDesktop {
Write-Output "Disabling Remote Desktop..."
SetRegistryKey "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" "fDenyTSConnections" "DWord" 1
SetRegistryKey "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" "UserAuthentication" "DWord" 1
}
# Disable Autoplay
Function DisableAutoplay {
Write-Output "Disabling Autoplay..."
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" "DisableAutoplay" "DWord" 1
}
# Enable Autoplay
Function EnableAutoplay {
Write-Output "Enabling Autoplay..."
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" "DisableAutoplay" "DWord" 0
}
# Disable Autorun for all drives
Function DisableAutorun {
Write-Output "Disabling Autorun for all drives..."
SetRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" "NoDriveTypeAutoRun" "DWord" 255
}
# Enable Autorun for removable drives
Function EnableAutorun {
Write-Output "Enabling Autorun for all drives..."
DeleteRegistryKey "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" "NoDriveTypeAutoRun"
}
# Enable Storage Sense - automatic disk cleanup - Not applicable to Server
Function EnableStorageSense {
Write-Output "Enabling Storage Sense..."
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" "01" "DWord" 1
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" "04" "DWord" 1
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" "08" "DWord" 1
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" "32" "DWord" 0
SetRegistryKey "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" "StoragePoliciesNotified" "DWord" 1
}
# Disable Storage Sense - Not applicable to Server
Function DisableStorageSense {
Write-Output "Disabling Storage Sense..."
Remove-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" -Recurse -ErrorAction SilentlyContinue
}
# Disable scheduled defragmentation task
Function DisableDefragmentation {
Write-Output "Disabling scheduled defragmentation..."
Disable-ScheduledTask -TaskName "Microsoft\Windows\Defrag\ScheduledDefrag" | Out-Null
}
# Enable scheduled defragmentation task
Function EnableDefragmentation {
Write-Output "Enabling scheduled defragmentation..."