Advertisement
BlackDragonBE

Windows 10 Easy Optimization With GPD Win Tweaks

Jun 21st, 2017
28,281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ##########
  2. # Win10 Optimization Script With Extra GPD Win Tweaks
  3. # Adapted version of https://github.com/Disassembler0/Win10-Initial-Setup-Script by Disassembler <disassembler@dasm.cz>
  4. # Author: BlackDragonBE
  5. # Version: v2.4 (2017-12-27)
  6. ##########
  7.  
  8. # As a workaround for disabled script execution, run this command (without #) in an elevated PowerShell windows first and choose "all" if you're asked where to apply this:
  9. # Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
  10.  
  11. <#
  12. Release Notes:
  13.  
  14. v2.0
  15. - Complete overhaul, fully based on https://github.com/Disassembler0/Win10-Initial-Setup-Script now
  16. - Migrated my tweaks to the new system
  17.  
  18. v2.1
  19. - More GPD Win service tweaks
  20. - Even more services to disable
  21. - More features/components removed
  22. - Disable the compatibility appraiser
  23. - Minor cleanup
  24. - Enabled more default tweaks
  25.  
  26. v2.2
  27. - Improved the way applications get installed by Ninite, you can now easily decide what apps (not) to install
  28.  
  29. v2.2.1
  30. - Fixed Ninite install bug causing the script to endlessly loop (yikes!)
  31. - Tried to keep some reg edits more silent
  32.  
  33. v2.3
  34. - Added more bloatware removal (39a1d90)
  35.  
  36. v2.4
  37. - Fixed reboot prompt
  38.  
  39. Copyright:
  40.  
  41. MIT License
  42.  
  43. Copyright (c) 2017 BlackDragonBE
  44.  
  45. Permission is hereby granted, free of charge, to any person obtaining a copy
  46. of this software and associated documentation files (the "Software"), to deal
  47. in the Software without restriction, including without limitation the rights
  48. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  49. copies of the Software, and to permit persons to whom the Software is
  50. furnished to do so, subject to the following conditions:
  51.  
  52. The above copyright notice and this permission notice shall be included in all
  53. copies or substantial portions of the Software.
  54.  
  55. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  56. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  57. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  58. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  59. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  60. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  61. SOFTWARE.
  62.  
  63. #>
  64.  
  65. # Tweaks
  66. # A # in front means it won't run.
  67. $tweaks = @(
  68.     ### Require administrator privileges ###
  69.     "RequireAdmin",
  70.  
  71.     ### Privacy Settings ###
  72.     "DisableTelemetry",             # "EnableTelemetry",
  73.     "DisableWiFiSense",             # "EnableWiFiSense",
  74.     "DisableSmartScreen",           # "EnableSmartScreen",
  75.     "DisableWebSearch",             # "EnableWebSearch",
  76.     "DisableAppSuggestions",        # "EnableAppSuggestions",
  77.     "DisableBackgroundApps",        # "EnableBackgroundApps",
  78.     "DisableLockScreenSpotlight",   # "EnableLockScreenSpotlight",
  79.     "DisableLocationTracking",      # "EnableLocationTracking",
  80.     "DisableMapUpdates",            # "EnableMapUpdates",
  81.     "DisableFeedback",              # "EnableFeedback",
  82.     "DisableAdvertisingID",         # "EnableAdvertisingID",
  83.     "DisableCortana",               # "EnableCortana",
  84.     "DisableErrorReporting",        # "EnableErrorReporting",
  85.     "SetP2PUpdateLocal",            # "SetP2PUpdateInternet",
  86.     "DisableAutoLogger",            # "EnableAutoLogger",
  87.     "DisableDiagTrack",             # "EnableDiagTrack",
  88.     "DisableWAPPush",               # "EnableWAPPush",
  89.  
  90.     ### Service Tweaks ###
  91.     "SetUACLow",                    # "SetUACHigh",
  92.     # "EnableSharingMappedDrives",  # "DisableSharingMappedDrives",
  93.     "DisableAdminShares",           # "EnableAdminShares",
  94.     # "DisableSMB1",                # "EnableSMB1",
  95.     "SetCurrentNetworkPrivate",     # "SetCurrentNetworkPublic",
  96.     # "SetUnknownNetworksPrivate",  # "SetUnknownNetworksPublic",
  97.     "EnableCtrldFolderAccess",      # "DisableCtrldFolderAccess",
  98.     # "DisableFirewall",            # "EnableFirewall",
  99.     # "DisableDefender",            # "EnableDefender",
  100.     # "DisableDefenderCloud",       # "EnableDefenderCloud",
  101.     # "DisableUpdateMSRT",          # "EnableUpdateMSRT",
  102.     # "DisableUpdateDriver",        # "EnableUpdateDriver",
  103.     "DisableUpdateRestart",         # "EnableUpdateRestart",
  104.     "DisableHomeGroups",            # "EnableHomeGroups",
  105.     "DisableSharedExperiences",     # "EnableSharedExperiences",
  106.     "DisableRemoteAssistance",      # "EnableRemoteAssistance",
  107.     "DisableRemoteDesktop",         # "EnableRemoteDesktop",
  108.     "DisableAutoplay",              # "EnableAutoplay",
  109.     "DisableAutorun",               # "EnableAutorun",
  110.     "EnableStorageSense",           # "DisableStorageSense",
  111.     # "DisableDefragmentation",     # "EnableDefragmentation",
  112.     "DisableSuperfetch",            # "EnableSuperfetch",
  113.     "DisableIndexing",              # "EnableIndexing",
  114.     # "SetBIOSTimeUTC",             # "SetBIOSTimeLocal",
  115.     "DisableHibernation",           # "EnableHibernation",
  116.     "DisableFastStartup",           # "EnableFastStartup",
  117.  
  118.     ### UI Tweaks ###
  119.     # "DisableActionCenter",        # "EnableActionCenter",
  120.     "DisableLockScreen",            # "EnableLockScreen",
  121.     "DisableLockScreenRS1",         # "EnableLockScreenRS1",
  122.     "HideNetworkFromLockScreen",    # "ShowNetworkOnLockScreen",
  123.     "HideShutdownFromLockScreen",   # "ShowShutdownOnLockScreen",
  124.     "DisableStickyKeys",            # "EnableStickyKeys",
  125.     "ShowTaskManagerDetails"        # "HideTaskManagerDetails",
  126.     "ShowFileOperationsDetails",    # "HideFileOperationsDetails",
  127.     # "EnableFileDeleteConfirm",    # "DisableFileDeleteConfirm",
  128.     "HideTaskbarSearchBox",         # "ShowTaskbarSearchBox",
  129.     "HideTaskView",                 # "ShowTaskView",
  130.     "ShowSmallTaskbarIcons",        # "ShowLargeTaskbarIcons",
  131.     "ShowTaskbarTitles",            # "HideTaskbarTitles",
  132.     "HideTaskbarPeopleIcon",        # "ShowTaskbarPeopleIcon",
  133.     "ShowTrayIcons",                # "HideTrayIcons",
  134.     "ShowKnownExtensions",          # "HideKnownExtensions",
  135.     "ShowHiddenFiles",              # "HideHiddenFiles",
  136.     "HideSyncNotifications"         # "ShowSyncNotifications",
  137.     "HideRecentShortcuts",          # "ShowRecentShortcuts",
  138.     "SetExplorerThisPC",            # "SetExplorerQuickAccess",
  139.     "ShowThisPCOnDesktop",          # "HideThisPCFromDesktop",
  140.     # "ShowUserFolderOnDesktop",    # "HideUserFolderFromDesktop",
  141.     # "HideDesktopFromThisPC",      # "ShowDesktopInThisPC",
  142.     "HideDocumentsFromThisPC",      # "ShowDocumentsInThisPC",
  143.     "HideDownloadsFromThisPC",    # "ShowDownloadsInThisPC",
  144.     "HideMusicFromThisPC",        # "ShowMusicInThisPC",
  145.     "HidePicturesFromThisPC",     # "ShowPicturesInThisPC",
  146.     "HideVideosFromThisPC",       # "ShowVideosInThisPC",
  147.     "Hide3DObjectsFromThisPC",      # "Show3DObjectsInThisPC",
  148.     "SetVisualFXPerformance",       # "SetVisualFXAppearance",
  149.     # "DisableThumbnails",          # "EnableThumbnails",
  150.     "DisableThumbsDB",              # "EnableThumbsDB",
  151.     # "AddENKeyboard",                # "RemoveENKeyboard",
  152.     "EnableNumlock",                # "DisableNumlock",
  153.  
  154.     ### Application Tweaks ###
  155.     "DisableOneDrive",              # "EnableOneDrive",
  156.     "UninstallOneDrive",            # "InstallOneDrive",
  157.     "UninstallMsftBloat",           # "InstallMsftBloat",
  158.     "UninstallThirdPartyBloat",     # "InstallThirdPartyBloat",
  159.     # "UninstallWindowsStore",      # "InstallWindowsStore",
  160.     "DisableXboxFeatures",          # "EnableXboxFeatures",
  161.     "DisableAdobeFlash",            # "EnableAdobeFlash",
  162.     "UninstallMediaPlayer",         # "InstallMediaPlayer",
  163.     "UninstallWorkFolders",         # "InstallWorkFolders",
  164.     # "InstallLinuxSubsystem",      # "UninstallLinuxSubsystem",
  165.     # "InstallHyperV",              # "UninstallHyperV",
  166.     # "SetPhotoViewerAssociation",  # "UnsetPhotoViewerAssociation",
  167.     "AddPhotoViewerOpenWith",       # "RemovePhotoViewerOpenWith",
  168.     "DisableSearchAppInStore",      # "EnableSearchAppInStore",
  169.     "DisableNewAppPrompt",          # "EnableNewAppPrompt",
  170.     "EnableF8BootMenu",             # "DisableF8BootMenu",
  171.     "SetDEPOptOut",                 # "SetDEPOptIn",
  172.    
  173.     ### BlackDragonBE Tweaks ###
  174.     "DisableExtraServices",
  175.     "DoNiniteInstall", # Note: check the list below and choose what you want installed
  176.     "DeleteTempFiles",
  177.     "CleanWinSXS", # Takes a whie but frees up a lot of space
  178.     "DownloadShutup10",
  179.     "RemoveUnneededComponents",
  180.     "DisableWindowsSearch",         # "EnableWindowsSearch",
  181.     "DisableCompatibilityAppraiser",
  182.    
  183.     ### GPD Win Specific Tweaks ###
  184.     "DisableConnectedStandby",
  185.     "DisableHibernation",
  186.     "DisableUpdateDriver", #Added here as well as it's so important for the WIN
  187.     "EnableBigDesktopIcons",
  188.     "DisableGPDWinServices",
  189.  
  190.     ### Server Specific Tweaks ###
  191.     # "HideServerManagerOnLogin",   # "ShowServerManagerOnLogin",
  192.     # "DisableShutdownTracker",     # "EnableShutdownTracker",
  193.     # "DisablePasswordPolicy",      # "EnablePasswordPolicy",
  194.     # "DisableCtrlAltDelLogin",     # "EnableCtrlAltDelLogin",
  195.     # "DisableIEEnhancedSecurity",  # "EnableIEEnhancedSecurity",
  196.  
  197.     ### Auxiliary Functions ###
  198.     "WaitForKey",
  199.     "Restart"
  200. )
  201.  
  202. # Ninite Apps
  203. # A # in front means it won't install
  204. $niniteapps = @(
  205.     ".net4.7",
  206.     "7zip",
  207.     # "adaware",
  208.     # "aimp",
  209.     # "air",
  210.     "audacity",
  211.     # "avast",
  212.     # "avg",
  213.     # "avira",
  214.     # "cccp",
  215.     # "cdburnerxp",
  216.     "chrome",
  217.     # "classicstart",
  218.     "cutepdf",
  219.     # "dropbox",
  220.     # "eclipse",
  221.     # "emule",
  222.     # "essentials",
  223.     "evernote",
  224.     "everything",
  225.     # "faststone",
  226.     # "filezilla",
  227.     # "firefox",
  228.     # "foobar",
  229.     "foxit",
  230.     # "gimp",
  231.     # "glary",
  232.     # "gom",
  233.     # "googledrive",
  234.     # "googleearth",
  235.     # "greenshot",
  236.     # "handbrake",
  237.     # "imgburn",
  238.     # "infrarecorder",
  239.     "inkscape",
  240.     # "irfanview",
  241.     # "itunes",
  242.     # "java8",
  243.     # "jdk8",
  244.     # "jdkx8",
  245.     # "keepass2",
  246.     "klitecodecs",
  247.     # "launchy",
  248.     # "libreoffice",
  249.     # "malwarebytes",
  250.     # "mediamonkey",
  251.     # "mozy",
  252.     # "musicbee",
  253.     "notepadplusplus",
  254.     # "nvda",
  255.     # "onedrive",
  256.     # "openoffice",
  257.     # "operaChromium",
  258.     # "paint.net",
  259.     # "pdfcreator",
  260.     # "peazip",
  261.     # "pidgin",
  262.     # "putty",
  263.     # "python",
  264.     "qbittorrent",
  265.     # "realvnc",
  266.     # "revo",
  267.     # "shockwave",
  268.     # "silverlight",
  269.     "skype",
  270.     # "spotify",
  271.     # "spybot2",
  272.     "steam",
  273.     # "sugarsync",
  274.     # "sumatrapdf",
  275.     # "super",
  276.     "teamviewer12",
  277.     # "teracopy",
  278.     # "thunderbird",
  279.     # "trillian",
  280.     # "vlc",
  281.     # "vscode",
  282.     # "winamp",
  283.     "windirstat",
  284.     # "winmerge",
  285.     # "winrar",
  286.     # "winscp",
  287.     "xnview"
  288. )
  289.  
  290.  
  291.  
  292. ##########
  293. # Privacy Settings
  294. ##########
  295.  
  296. # Disable Telemetry
  297. Function DisableTelemetry {
  298.     Write-Host "Disabling Telemetry..."
  299.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0
  300.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0
  301.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0
  302. }
  303.  
  304. # Enable Telemetry
  305. Function EnableTelemetry {
  306.     Write-Host "Enabling Telemetry..."
  307.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 3
  308.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 3
  309.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 3
  310. }
  311.  
  312. # Disable Wi-Fi Sense
  313. Function DisableWiFiSense {
  314.     Write-Host "Disabling Wi-Fi Sense..."
  315.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting")) {
  316.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" -Force | Out-Null
  317.     }
  318.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" -Name "Value" -Type DWord -Value 0
  319.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots" -Name "Value" -Type DWord -Value 0
  320. }
  321.  
  322. # Enable Wi-Fi Sense
  323. Function EnableWiFiSense {
  324.     Write-Host "Enabling Wi-Fi Sense..."
  325.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting")) {
  326.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" -Force | Out-Null
  327.     }
  328.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" -Name "Value" -Type DWord -Value 1
  329.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots" -Name "Value" -Type DWord -Value 1
  330. }
  331.  
  332. # Disable SmartScreen Filter
  333. Function DisableSmartScreen {
  334.     Write-Host "Disabling SmartScreen Filter..."
  335.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "SmartScreenEnabled" -Type String -Value "Off"
  336.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost" -Name "EnableWebContentEvaluation" -Type DWord -Value 0
  337.     $edge = (Get-AppxPackage -AllUsers "Microsoft.MicrosoftEdge").PackageFamilyName
  338.     If (!(Test-Path "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter")) {
  339.         New-Item -Path "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" -Force | Out-Null
  340.     }
  341.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" -Name "EnabledV9" -Type DWord -Value 0
  342.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" -Name "PreventOverride" -Type DWord -Value 0
  343. }
  344.  
  345. # Enable SmartScreen Filter
  346. Function EnableSmartScreen {
  347.     Write-Host "Enabling SmartScreen Filter..."
  348.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "SmartScreenEnabled" -Type String -Value "RequireAdmin"
  349.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost" -Name "EnableWebContentEvaluation" -ErrorAction SilentlyContinue
  350.     $edge = (Get-AppxPackage -AllUsers "Microsoft.MicrosoftEdge").PackageFamilyName
  351.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" -Name "EnabledV9" -ErrorAction SilentlyContinue
  352.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\$edge\MicrosoftEdge\PhishingFilter" -Name "PreventOverride" -ErrorAction SilentlyContinue
  353. }
  354.  
  355. # Disable Web Search in Start Menu
  356. Function DisableWebSearch {
  357.     Write-Host "Disabling Bing Search in Start Menu..."
  358.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" -Name "BingSearchEnabled" -Type DWord -Value 0
  359.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) {
  360.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null
  361.     }
  362.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "DisableWebSearch" -Type DWord -Value 1
  363. }
  364.  
  365. # Enable Web Search in Start Menu
  366. Function EnableWebSearch {
  367.     Write-Host "Enabling Bing Search in Start Menu..."
  368.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" -Name "BingSearchEnabled" -ErrorAction SilentlyContinue
  369.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "DisableWebSearch" -ErrorAction SilentlyContinue
  370. }
  371.  
  372. # Disable Application suggestions and automatic installation
  373. Function DisableAppSuggestions {
  374.     Write-Host "Disabling Application suggestions..."
  375.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "ContentDeliveryAllowed" -Type DWord -Value 0
  376.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "OemPreInstalledAppsEnabled" -Type DWord -Value 0
  377.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "PreInstalledAppsEnabled" -Type DWord -Value 0
  378.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "PreInstalledAppsEverEnabled" -Type DWord -Value 0
  379.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SilentInstalledAppsEnabled" -Type DWord -Value 0
  380.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338389Enabled" -Type DWord -Value 0
  381.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SystemPaneSuggestionsEnabled" -Type DWord -Value 0
  382.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338388Enabled" -Type DWord -Value 0
  383.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent")) {
  384.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Force | Out-Null
  385.     }
  386.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableWindowsConsumerFeatures" -Type DWord -Value 1
  387. }
  388.  
  389. # Enable Application suggestions and automatic installation
  390. Function EnableAppSuggestions {
  391.     Write-Host "Enabling Application suggestions..."
  392.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "ContentDeliveryAllowed" -Type DWord -Value 1
  393.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "OemPreInstalledAppsEnabled" -Type DWord -Value 1
  394.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "PreInstalledAppsEnabled" -Type DWord -Value 1
  395.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "PreInstalledAppsEverEnabled" -Type DWord -Value 1
  396.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SilentInstalledAppsEnabled" -Type DWord -Value 1
  397.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338389Enabled" -Type DWord -Value 1
  398.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SystemPaneSuggestionsEnabled" -Type DWord -Value 1
  399.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338388Enabled" -ErrorAction SilentlyContinue
  400.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableWindowsConsumerFeatures" -ErrorAction SilentlyContinue
  401. }
  402.  
  403. # Disable Background application access - ie. if apps can download or update even when they aren't used
  404. Function DisableBackgroundApps {
  405.     Write-Host "Disabling Background application access..."
  406.     Get-ChildItem "HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications" | ForEach-Object {
  407.         Set-ItemProperty -Path $_.PsPath -Name "Disabled" -Type DWord -Value 1
  408.         Set-ItemProperty -Path $_.PsPath -Name "DisabledByUser" -Type DWord -Value 1
  409.     }
  410. }
  411.  
  412. # Enable Background application access
  413. Function EnableBackgroundApps {
  414.     Write-Host "Enabling Background application access..."
  415.     Get-ChildItem "HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications" | ForEach-Object {
  416.         Remove-ItemProperty -Path $_.PsPath -Name "Disabled" -ErrorAction SilentlyContinue
  417.         Remove-ItemProperty -Path $_.PsPath -Name "DisabledByUser" -ErrorAction SilentlyContinue
  418.     }
  419. }
  420.  
  421. # Disable Lock screen Spotlight - New backgrounds, tips, advertisements etc.
  422. Function DisableLockScreenSpotlight {
  423.     Write-Host "Disabling Lock screen spotlight..."
  424.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "RotatingLockScreenEnabled" -Type DWord -Value 0
  425.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "RotatingLockScreenOverlayEnabled" -Type DWord -Value 0
  426.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338387Enabled" -Type DWord -Value 0
  427. }
  428.  
  429. # Enable Lock screen Spotlight
  430. Function EnableLockScreenSpotlight {
  431.     Write-Host "Disabling Lock screen spotlight..."
  432.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "RotatingLockScreenEnabled" -Type DWord -Value 1
  433.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "RotatingLockScreenOverlayEnabled" -Type DWord -Value 1
  434.     Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338387Enabled" -ErrorAction SilentlyContinue
  435. }
  436.  
  437. # Disable Location Tracking
  438. Function DisableLocationTracking {
  439.     Write-Host "Disabling Location Tracking..."
  440.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}" -Name "SensorPermissionState" -Type DWord -Value 0
  441.     Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration" -Name "Status" -Type DWord -Value 0
  442. }
  443.  
  444. # Enable Location Tracking
  445. Function EnableLocationTracking {
  446.     Write-Host "Enabling Location Tracking..."
  447.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Sensor\Overrides\{BFA794E4-F964-4FDB-90F6-51056BFE4B44}" -Name "SensorPermissionState" -Type DWord -Value 1
  448.     Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\lfsvc\Service\Configuration" -Name "Status" -Type DWord -Value 1
  449. }
  450.  
  451. # Disable automatic Maps updates
  452. Function DisableMapUpdates {
  453.     Write-Host "Disabling automatic Maps updates..."
  454.     Set-ItemProperty -Path "HKLM:\SYSTEM\Maps" -Name "AutoUpdateEnabled" -Type DWord -Value 0
  455. }
  456.  
  457. # Enable automatic Maps updates
  458. Function EnableMapUpdates {
  459.     Write-Host "Enable automatic Maps updates..."
  460.     Remove-ItemProperty -Path "HKLM:\SYSTEM\Maps" -Name "AutoUpdateEnabled" -ErrorAction SilentlyContinue
  461. }
  462.  
  463. # Disable Feedback
  464. Function DisableFeedback {
  465.     Write-Host "Disabling Feedback..."
  466.     If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules")) {
  467.         New-Item -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" -Force | Out-Null
  468.     }
  469.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" -Name "NumberOfSIUFInPeriod" -Type DWord -Value 0
  470. }
  471.  
  472. # Enable Feedback
  473. Function EnableFeedback {
  474.     Write-Host "Enabling Feedback..."
  475.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Siuf\Rules" -Name "NumberOfSIUFInPeriod" -ErrorAction SilentlyContinue
  476. }
  477.  
  478. # Disable Advertising ID
  479. Function DisableAdvertisingID {
  480.     Write-Host "Disabling Advertising ID..."
  481.     If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo")) {
  482.         New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo" | Out-Null
  483.     }
  484.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo" -Name "Enabled" -Type DWord -Value 0
  485.     If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy")) {
  486.         New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy" | Out-Null
  487.     }
  488.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy" -Name "TailoredExperiencesWithDiagnosticDataEnabled" -Type DWord -Value 0
  489. }
  490.  
  491. # Enable Advertising ID
  492. Function EnableAdvertisingID {
  493.     Write-Host "Enabling Advertising ID..."
  494.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo" -Name "Enabled" -ErrorAction SilentlyContinue
  495.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy" -Name "TailoredExperiencesWithDiagnosticDataEnabled" -Type DWord -Value 2
  496. }
  497.  
  498. # Disable Cortana
  499. Function DisableCortana {
  500.     Write-Host "Disabling Cortana..."
  501.     If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings")) {
  502.         New-Item -Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" -Force | Out-Null
  503.     }
  504.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" -Name "AcceptedPrivacyPolicy" -Type DWord -Value 0
  505.     If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization")) {
  506.         New-Item -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Force | Out-Null
  507.     }
  508.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitTextCollection" -Type DWord -Value 1
  509.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitInkCollection" -Type DWord -Value 1
  510.     If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore")) {
  511.         New-Item -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" -Force | Out-Null
  512.     }
  513.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" -Name "HarvestContacts" -Type DWord -Value 0
  514.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) {
  515.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null
  516.     }
  517.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "AllowCortana" -Type DWord -Value 0
  518. }
  519.  
  520. # Enable Cortana
  521. Function EnableCortana {
  522.     Write-Host "Enabling Cortana..."
  523.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Personalization\Settings" -Name "AcceptedPrivacyPolicy" -ErrorAction SilentlyContinue
  524.     If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore")) {
  525.         New-Item -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" -Force | Out-Null
  526.     }
  527.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitTextCollection" -Type DWord -Value 0
  528.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitInkCollection" -Type DWord -Value 0
  529.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\InputPersonalization\TrainedDataStore" -Name "HarvestContacts" -ErrorAction SilentlyContinue
  530.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "AllowCortana" -ErrorAction SilentlyContinue
  531. }
  532.  
  533. # Disable Error reporting
  534. Function DisableErrorReporting {
  535.     Write-Host "Disabling Error reporting..."
  536.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name "Disabled" -Type DWord -Value 1
  537. }
  538.  
  539. # Enable Error reporting
  540. Function EnableErrorReporting {
  541.     Write-Host "Enabling Error reporting..."
  542.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name "Disabled" -ErrorAction SilentlyContinue
  543. }
  544.  
  545. # Restrict Windows Update P2P only to local network
  546. Function SetP2PUpdateLocal {
  547.     Write-Host "Restricting Windows Update P2P only to local network..."
  548.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config")) {
  549.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" | Out-Null
  550.     }
  551.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -Type DWord -Value 1
  552.     If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization")) {
  553.         New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization" | Out-Null
  554.     }
  555.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization" -Name "SystemSettingsDownloadMode" -Type DWord -Value 3
  556. }
  557.  
  558. # Unrestrict Windows Update P2P
  559. Function SetP2PUpdateInternet {
  560.     Write-Host "Unrestricting Windows Update P2P to internet..."
  561.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -ErrorAction SilentlyContinue
  562.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization" -Name "SystemSettingsDownloadMode" -ErrorAction SilentlyContinue
  563. }
  564.  
  565. # Remove AutoLogger file and restrict directory
  566. Function DisableAutoLogger {
  567.     Write-Host "Removing AutoLogger file and restricting directory..."
  568.     $autoLoggerDir = "$env:PROGRAMDATA\Microsoft\Diagnosis\ETLLogs\AutoLogger"
  569.     If (Test-Path "$autoLoggerDir\AutoLogger-Diagtrack-Listener.etl") {
  570.         Remove-Item "$autoLoggerDir\AutoLogger-Diagtrack-Listener.etl"
  571.     }
  572.     icacls $autoLoggerDir /deny SYSTEM:`(OI`)`(CI`)F | Out-Null
  573. }
  574.  
  575. # Unrestrict AutoLogger directory
  576. Function EnableAutoLogger {
  577.     Write-Host "Unrestricting AutoLogger directory..."
  578.     $autoLoggerDir = "$env:PROGRAMDATA\Microsoft\Diagnosis\ETLLogs\AutoLogger"
  579.     icacls $autoLoggerDir /grant:r SYSTEM:`(OI`)`(CI`)F | Out-Null
  580. }
  581.  
  582. # Stop and disable Diagnostics Tracking Service
  583. Function DisableDiagTrack {
  584.     Write-Host "Stopping and disabling Diagnostics Tracking Service..."
  585.     Stop-Service "DiagTrack" -WarningAction SilentlyContinue
  586.     Set-Service "DiagTrack" -StartupType Disabled
  587. }
  588.  
  589. # Enable and start Diagnostics Tracking Service
  590. Function EnableDiagTrack {
  591.     Write-Host "Enabling and starting Diagnostics Tracking Service..."
  592.     Set-Service "DiagTrack" -StartupType Automatic
  593.     Start-Service "DiagTrack" -WarningAction SilentlyContinue
  594. }
  595.  
  596. # Stop and disable WAP Push Service
  597. Function DisableWAPPush {
  598.     Write-Host "Stopping and disabling WAP Push Service..."
  599.     Stop-Service "dmwappushservice" -WarningAction SilentlyContinue
  600.     Set-Service "dmwappushservice" -StartupType Disabled
  601. }
  602.  
  603. # Enable and start WAP Push Service
  604. Function EnableWAPPush {
  605.     Write-Host "Enabling and starting WAP Push Service..."
  606.     Set-Service "dmwappushservice" -StartupType Automatic
  607.     Start-Service "dmwappushservice" -WarningAction SilentlyContinue
  608.     Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\dmwappushservice" -Name "DelayedAutoStart" -Type DWord -Value 1
  609. }
  610.  
  611.  
  612.  
  613. ##########
  614. # Service Tweaks
  615. ##########
  616.  
  617. # Lower UAC level (disabling it completely would break apps)
  618. Function SetUACLow {
  619.     Write-Host "Lowering UAC level..."
  620.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Type DWord -Value 0
  621.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "PromptOnSecureDesktop" -Type DWord -Value 0
  622. }
  623.  
  624. # Raise UAC level
  625. Function SetUACHigh {
  626.     Write-Host "Raising UAC level..."
  627.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Type DWord -Value 5
  628.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "PromptOnSecureDesktop" -Type DWord -Value 1
  629. }
  630.  
  631. # Enable sharing mapped drives between users
  632. Function EnableSharingMappedDrives {
  633.     Write-Host "Enabling sharing mapped drives between users..."
  634.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLinkedConnections" -Type DWord -Value 1
  635. }
  636.  
  637. # Disable sharing mapped drives between users
  638. Function DisableSharingMappedDrives {
  639.     Write-Host "Disabling sharing mapped drives between users..."
  640.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLinkedConnections" -ErrorAction SilentlyContinue
  641. }
  642.  
  643. # Disable implicit administrative shares
  644. Function DisableAdminShares {
  645.     Write-Host "Disabling implicit administrative shares..."
  646.     Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" -Name "AutoShareWks" -Type DWord -Value 0
  647. }
  648.  
  649. # Enable implicit administrative shares
  650. Function EnableAdminShares {
  651.     Write-Host "Enabling implicit administrative shares..."
  652.     Remove-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" -Name "AutoShareWks" -ErrorAction SilentlyContinue
  653. }
  654.  
  655. # Disable obsolete SMB 1.0 protocol - Disabled by default since 1709
  656. Function DisableSMB1 {
  657.     Write-Host "Disabling SMB 1.0 protocol..."
  658.     Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force
  659. }
  660.  
  661. # Enable obsolete SMB 1.0 protocol - Disabled by default since 1709
  662. Function EnableSMB1 {
  663.     Write-Host "Enabling SMB 1.0 protocol..."
  664.     Set-SmbServerConfiguration -EnableSMB1Protocol $true -Force
  665. }
  666.  
  667. # Set current network profile to private (allow file sharing, device discovery, etc.)
  668. Function SetCurrentNetworkPrivate {
  669.     Write-Host "Setting current network profile to private..."
  670.     Set-NetConnectionProfile -NetworkCategory Private
  671. }
  672.  
  673. # Set current network profile to public (deny file sharing, device discovery, etc.)
  674. Function SetCurrentNetworkPublic {
  675.     Write-Host "Setting current network profile to public..."
  676.     Set-NetConnectionProfile -NetworkCategory Public
  677. }
  678.  
  679. # Set unknown networks profile to private (allow file sharing, device discovery, etc.)
  680. Function SetUnknownNetworksPrivate {
  681.     Write-Host "Setting unknown networks profile to private..."
  682.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\010103000F0000F0010000000F0000F0C967A3643C3AD745950DA7859209176EF5B87C875FA20DF21951640E807D7C24")) {
  683.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\010103000F0000F0010000000F0000F0C967A3643C3AD745950DA7859209176EF5B87C875FA20DF21951640E807D7C24" -Force | Out-Null
  684.     }
  685.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\010103000F0000F0010000000F0000F0C967A3643C3AD745950DA7859209176EF5B87C875FA20DF21951640E807D7C24" -Name "Category" -Type DWord -Value 1
  686. }
  687.  
  688. # Set unknown networks profile to public (deny file sharing, device discovery, etc.)
  689. Function SetUnknownNetworksPublic {
  690.     Write-Host "Setting unknown networks profile to public..."
  691.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\010103000F0000F0010000000F0000F0C967A3643C3AD745950DA7859209176EF5B87C875FA20DF21951640E807D7C24" -Name "Category" -ErrorAction SilentlyContinue
  692. }
  693.  
  694. # Enable Controlled Folder Access (Defender Exploit Guard feature) - Not applicable to Server
  695. Function EnableCtrldFolderAccess {
  696.     Write-Host "Enabling Controlled Folder Access..."
  697.     Set-MpPreference -EnableControlledFolderAccess Enabled
  698. }
  699.  
  700. # Disable Controlled Folder Access (Defender Exploit Guard feature) - Not applicable to Server
  701. Function DisableCtrldFolderAccess {
  702.     Write-Host "Disabling Controlled Folder Access..."
  703.     Set-MpPreference -EnableControlledFolderAccess Disabled
  704. }
  705.  
  706. # Disable Firewall
  707. Function DisableFirewall {
  708.     Write-Host "Disabling Firewall..."
  709.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfile")) {
  710.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfile" -Force | Out-Null
  711.     }
  712.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfile" -Name "EnableFirewall" -Type DWord -Value 0
  713. }
  714.  
  715. # Enable Firewall
  716. Function EnableFirewall {
  717.     Write-Host "Enabling Firewall..."
  718.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfile" -Name "EnableFirewall" -ErrorAction SilentlyContinue
  719. }
  720.  
  721. # Disable Windows Defender
  722. Function DisableDefender {
  723.     Write-Host "Disabling Windows Defender..."
  724.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender")) {
  725.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Force | Out-Null
  726.     }
  727.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -Type DWord -Value 1
  728.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "SecurityHealth" -ErrorAction SilentlyContinue
  729. }
  730.  
  731. # Enable Windows Defender
  732. Function EnableDefender {
  733.     Write-Host "Enabling Windows Defender..."
  734.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -ErrorAction SilentlyContinue
  735.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "SecurityHealth" -Type ExpandString -Value "`"%ProgramFiles%\Windows Defender\MSASCuiL.exe`""
  736. }
  737.  
  738. # Disable Windows Defender Cloud
  739. Function DisableDefenderCloud {
  740.     Write-Host "Disabling Windows Defender Cloud..."
  741.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet")) {
  742.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Force | Out-Null
  743.     }
  744.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -Type DWord -Value 0
  745.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -Type DWord -Value 2
  746. }
  747.  
  748. # Enable Windows Defender Cloud
  749. Function EnableDefenderCloud {
  750.     Write-Host "Enabling Windows Defender Cloud..."
  751.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -ErrorAction SilentlyContinue
  752.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -ErrorAction SilentlyContinue
  753. }
  754.  
  755. # Disable offering of Malicious Software Removal Tool through Windows Update
  756. Function DisableUpdateMSRT {
  757.     Write-Host "Disabling Malicious Software Removal Tool offering..."
  758.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT")) {
  759.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" | Out-Null
  760.     }
  761.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" -Name "DontOfferThroughWUAU" -Type DWord -Value 1
  762. }
  763.  
  764. # Enable offering of Malicious Software Removal Tool through Windows Update
  765. Function EnableUpdateMSRT {
  766.     Write-Host "Enabling Malicious Software Removal Tool offering..."
  767.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" -Name "DontOfferThroughWUAU" -ErrorAction SilentlyContinue
  768. }
  769.  
  770. # Disable offering of drivers through Windows Update
  771. Function DisableUpdateDriver {
  772.     Write-Host "Disabling driver offering through Windows Update..."
  773.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching" -Name "SearchOrderConfig" -Type DWord -Value 0
  774.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate")) {
  775.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" | Out-Null
  776.     }
  777.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ExcludeWUDriversInQualityUpdate" -Type DWord -Value 1
  778. }
  779.  
  780. # Enable offering of drivers through Windows Update
  781. Function EnableUpdateDriver {
  782.     Write-Host "Enabling driver offering through Windows Update..."
  783.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DriverSearching" -Name "SearchOrderConfig" -Type DWord -Value 1
  784.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ExcludeWUDriversInQualityUpdate" -ErrorAction SilentlyContinue
  785. }
  786.  
  787. # Disable Windows Update automatic restart
  788. Function DisableUpdateRestart {
  789.     Write-Host "Disabling Windows Update automatic restart..."
  790.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU")) {
  791.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Force | Out-Null
  792.     }
  793.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "NoAutoRebootWithLoggedOnUsers" -Type DWord -Value 1
  794.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUPowerManagement" -Type DWord -Value 0
  795. }
  796.  
  797. # Enable Windows Update automatic restart
  798. Function EnableUpdateRestart {
  799.     Write-Host "Enabling Windows Update automatic restart..."
  800.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "NoAutoRebootWithLoggedOnUsers" -ErrorAction SilentlyContinue
  801.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUPowerManagement" -ErrorAction SilentlyContinue
  802. }
  803.  
  804. # Stop and disable Home Groups services - Not applicable to Server
  805. Function DisableHomeGroups {
  806.     Write-Host "Stopping and disabling Home Groups services..."
  807.     Stop-Service "HomeGroupListener" -WarningAction SilentlyContinue
  808.     Set-Service "HomeGroupListener" -StartupType Disabled
  809.     Stop-Service "HomeGroupProvider" -WarningAction SilentlyContinue
  810.     Set-Service "HomeGroupProvider" -StartupType Disabled
  811. }
  812.  
  813. # Enable and start Home Groups services - Not applicable to Server
  814. Function EnableHomeGroups {
  815.     Write-Host "Starting and enabling Home Groups services..."
  816.     Set-Service "HomeGroupListener" -StartupType Manual
  817.     Set-Service "HomeGroupProvider" -StartupType Manual
  818.     Start-Service "HomeGroupProvider" -WarningAction SilentlyContinue
  819. }
  820.  
  821. # Disable Shared Experiences - Not applicable to Server
  822. Function DisableSharedExperiences {
  823.     Write-Host "Disabling Shared Experiences..."
  824.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\CDP" -Name "RomeSdkChannelUserAuthzPolicy" -Type DWord -Value 0
  825. }
  826.  
  827. # Enable Shared Experiences - Not applicable to Server
  828. Function EnableSharedExperiences {
  829.     Write-Host "Enabling Shared Experiences..."
  830.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\CDP" -Name "RomeSdkChannelUserAuthzPolicy" -Type DWord -Value 1
  831. }
  832.  
  833. # Disable Remote Assistance - Not applicable to Server (unless Remote Assistance is explicitly installed)
  834. Function DisableRemoteAssistance {
  835.     Write-Host "Disabling Remote Assistance..."
  836.     Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Remote Assistance" -Name "fAllowToGetHelp" -Type DWord -Value 0
  837. }
  838.  
  839. # Enable Remote Assistance - Not applicable to Server (unless Remote Assistance is explicitly installed)
  840. Function EnableRemoteAssistance {
  841.     Write-Host "Enabling Remote Assistance..."
  842.     Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Remote Assistance" -Name "fAllowToGetHelp" -Type DWord -Value 1
  843. }
  844.  
  845. # Enable Remote Desktop w/o Network Level Authentication
  846. Function EnableRemoteDesktop {
  847.     Write-Host "Enabling Remote Desktop w/o Network Level Authentication..."
  848.     Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Type DWord -Value 0
  849.     Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "UserAuthentication" -Type DWord -Value 0
  850. }
  851.  
  852. # Disable Remote Desktop
  853. Function DisableRemoteDesktop {
  854.     Write-Host "Disabling Remote Desktop..."
  855.     Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Type DWord -Value 1
  856.     Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" -Name "UserAuthentication" -Type DWord -Value 1
  857. }
  858.  
  859. # Disable Autoplay
  860. Function DisableAutoplay {
  861.     Write-Host "Disabling Autoplay..."
  862.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name "DisableAutoplay" -Type DWord -Value 1
  863. }
  864.  
  865. # Enable Autoplay
  866. Function EnableAutoplay {
  867.     Write-Host "Enabling Autoplay..."
  868.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name "DisableAutoplay" -Type DWord -Value 0
  869. }
  870.  
  871. # Disable Autorun for all drives
  872. Function DisableAutorun {
  873.     Write-Host "Disabling Autorun for all drives..."
  874.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer")) {
  875.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" | Out-Null
  876.     }
  877.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoDriveTypeAutoRun" -Type DWord -Value 255
  878. }
  879.  
  880. # Enable Autorun for removable drives
  881. Function EnableAutorun {
  882.     Write-Host "Enabling Autorun for all drives..."
  883.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoDriveTypeAutoRun" -ErrorAction SilentlyContinue
  884. }
  885.  
  886. # Enable Storage Sense - automatic disk cleanup - Not applicable to Server
  887. Function EnableStorageSense {
  888.     Write-Host "Enabling Storage Sense..."
  889.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" -Name "01" -Type DWord -Value 1 -ErrorAction SilentlyContinue
  890. }
  891.  
  892. # Disable Storage Sense - Not applicable to Server
  893. Function DisableStorageSense {
  894.     Write-Host "Disabling Storage Sense..."
  895.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" -Name "01" -Type DWord -Value 0 -ErrorAction SilentlyContinue
  896. }
  897.  
  898. # Disable scheduled defragmentation task
  899. Function DisableDefragmentation {
  900.     Write-Host "Disabling scheduled defragmentation..."
  901.     Disable-ScheduledTask -TaskName "\Microsoft\Windows\Defrag\ScheduledDefrag" | Out-Null
  902. }
  903.  
  904. # Enable scheduled defragmentation task
  905. Function EnableDefragmentation {
  906.     Write-Host "Enabling scheduled defragmentation..."
  907.     Enable-ScheduledTask -TaskName "\Microsoft\Windows\Defrag\ScheduledDefrag" | Out-Null
  908. }
  909.  
  910. # Stop and disable Superfetch service - Not applicable to Server
  911. Function DisableSuperfetch {
  912.     Write-Host "Stopping and disabling Superfetch service..."
  913.     Stop-Service "SysMain" -WarningAction SilentlyContinue
  914.     Set-Service "SysMain" -StartupType Disabled
  915. }
  916.  
  917. # Start and enable Superfetch service - Not applicable to Server
  918. Function EnableSuperfetch {
  919.     Write-Host "Starting and enabling Superfetch service..."
  920.     Set-Service "SysMain" -StartupType Automatic
  921.     Start-Service "SysMain" -WarningAction SilentlyContinue
  922. }
  923.  
  924. # Stop and disable Windows Search indexing service
  925. Function DisableIndexing {
  926.     Write-Host "Stopping and disabling Windows Search indexing service..."
  927.     Stop-Service "WSearch" -WarningAction SilentlyContinue
  928.     Set-Service "WSearch" -StartupType Disabled
  929. }
  930.  
  931. # Start and enable Windows Search indexing service
  932. Function EnableIndexing {
  933.     Write-Host "Starting and enabling Windows Search indexing service..."
  934.     Set-Service "WSearch" -StartupType Automatic
  935.     Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\WSearch" -Name "DelayedAutoStart" -Type DWord -Value 1
  936.     Start-Service "WSearch" -WarningAction SilentlyContinue
  937. }
  938.  
  939. # Set BIOS time to UTC
  940. Function SetBIOSTimeUTC {
  941.     Write-Host "Setting BIOS time to UTC..."
  942.     Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" -Name "RealTimeIsUniversal" -Type DWord -Value 1
  943. }
  944.  
  945. # Set BIOS time to local time
  946. Function SetBIOSTimeLocal {
  947.     Write-Host "Setting BIOS time to Local time..."
  948.     Remove-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" -Name "RealTimeIsUniversal" -ErrorAction SilentlyContinue
  949. }
  950.  
  951. # Enable Hibernation - Do not use on Server with automatically started Hyper-V hvboot service as it may lead to BSODs (Win10 with Hyper-V is fine)
  952. Function EnableHibernation {
  953.     Write-Host "Enabling Hibernation..."
  954.     Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Session Manager\Power" -Name "HibernteEnabled" -Type Dword -Value 1
  955.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings")) {
  956.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings" | Out-Null
  957.     }
  958.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings" -Name "ShowHibernateOption" -Type Dword -Value 1
  959. }
  960.  
  961. # Disable Hibernation
  962. Function DisableHibernation {
  963.     Write-Host "Disabling Hibernation..."
  964.     Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Session Manager\Power" -Name "HibernteEnabled" -Type Dword -Value 0
  965.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings")) {
  966.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings" | Out-Null
  967.     }
  968.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings" -Name "ShowHibernateOption" -Type Dword -Value 0
  969. }
  970.  
  971. # Disable Fast Startup
  972. Function DisableFastStartup {
  973.     Write-Host "Disabling Fast Startup..."
  974.     Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power" -Name "HiberbootEnabled" -Type DWord -Value 0
  975. }
  976.  
  977. # Enable Fast Startup
  978. Function EnableFastStartup {
  979.     Write-Host "Enabling Fast Startup..."
  980.     Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power" -Name "HiberbootEnabled" -Type DWord -Value 1
  981. }
  982.  
  983. ##########
  984. # UI Tweaks
  985. ##########
  986.  
  987. # Disable Action Center
  988. Function DisableActionCenter {
  989.     Write-Host "Disabling Action Center..."
  990.     If (!(Test-Path "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer")) {
  991.         New-Item -Path "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer" | Out-Null
  992.     }
  993.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Name "DisableNotificationCenter" -Type DWord -Value 1
  994.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications" -Name "ToastEnabled" -Type DWord -Value 0
  995. }
  996.  
  997. # Enable Action Center
  998. Function EnableActionCenter {
  999.     Write-Host "Enabling Action Center..."
  1000.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Name "DisableNotificationCenter" -ErrorAction SilentlyContinue
  1001.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications" -Name "ToastEnabled" -ErrorAction SilentlyContinue
  1002. }
  1003.  
  1004. # Disable Lock screen
  1005. Function DisableLockScreen {
  1006.     Write-Host "Disabling Lock screen..."
  1007.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization")) {
  1008.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" | Out-Null
  1009.     }
  1010.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" -Name "NoLockScreen" -Type DWord -Value 1
  1011. }
  1012.  
  1013. # Enable Lock screen
  1014. Function EnableLockScreen {
  1015.     Write-Host "Enabling Lock screen..."
  1016.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" -Name "NoLockScreen" -ErrorAction SilentlyContinue
  1017. }
  1018.  
  1019. # Disable Lock screen (Anniversary Update workaround) - Applicable to 1607 or newer
  1020. Function DisableLockScreenRS1 {
  1021.     Write-Host "Disabling Lock screen using scheduler workaround..."
  1022.     $service = New-Object -com Schedule.Service
  1023.     $service.Connect()
  1024.     $task = $service.NewTask(0)
  1025.     $task.Settings.DisallowStartIfOnBatteries = $false
  1026.     $trigger = $task.Triggers.Create(9)
  1027.     $trigger = $task.Triggers.Create(11)
  1028.     $trigger.StateChange = 8
  1029.     $action = $task.Actions.Create(0)
  1030.     $action.Path = "reg.exe"
  1031.     $action.Arguments = "add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\SessionData /t REG_DWORD /v AllowLockScreen /d 0 /f"
  1032.     $service.GetFolder("\").RegisterTaskDefinition("Disable LockScreen", $task, 6, "NT AUTHORITY\SYSTEM", $null, 4) | Out-Null
  1033. }
  1034.  
  1035. # Enable Lock screen (Anniversary Update workaround) - Applicable to 1607 or newer
  1036. Function EnableLockScreenRS1 {
  1037.     Write-Host "Enabling Lock screen (removing scheduler workaround)..."
  1038.     Unregister-ScheduledTask -TaskName "Disable LockScreen" -Confirm:$false -ErrorAction SilentlyContinue
  1039. }
  1040.  
  1041. # Hide network options from Lock Screen
  1042. Function HideNetworkFromLockScreen {
  1043.     Write-Host "Hiding network options from Lock Screen..."
  1044.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "DontDisplayNetworkSelectionUI" -Type DWord -Value 1
  1045. }
  1046.  
  1047. # Show network options on lock screen
  1048. Function ShowNetworkOnLockScreen {
  1049.     Write-Host "Showing network options on Lock Screen..."
  1050.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "DontDisplayNetworkSelectionUI" -ErrorAction SilentlyContinue
  1051. }
  1052.  
  1053. # Hide shutdown options from Lock Screen
  1054. Function HideShutdownFromLockScreen {
  1055.     Write-Host "Hiding shutdown options from Lock Screen..."
  1056.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ShutdownWithoutLogon" -Type DWord -Value 0
  1057. }
  1058.  
  1059. # Show shutdown options on lock screen
  1060. Function ShowShutdownOnLockScreen {
  1061.     Write-Host "Showing shutdown options on Lock Screen..."
  1062.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ShutdownWithoutLogon" -Type DWord -Value 1
  1063. }
  1064.  
  1065. # Disable Sticky keys prompt
  1066. Function DisableStickyKeys {
  1067.     Write-Host "Disabling Sticky keys prompt..."
  1068.     Set-ItemProperty -Path "HKCU:\Control Panel\Accessibility\StickyKeys" -Name "Flags" -Type String -Value "506"
  1069. }
  1070.  
  1071. # Enable Sticky keys prompt
  1072. Function EnableStickyKeys {
  1073.     Write-Host "Enabling Sticky keys prompt..."
  1074.     Set-ItemProperty -Path "HKCU:\Control Panel\Accessibility\StickyKeys" -Name "Flags" -Type String -Value "510"
  1075. }
  1076.  
  1077. # Show Task Manager details
  1078. Function ShowTaskManagerDetails {
  1079.     Write-Host "Showing task manager details..."
  1080.     If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager")) {
  1081.         New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Force | Out-Null
  1082.     }
  1083.     $preferences = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -ErrorAction SilentlyContinue
  1084.     If (!($preferences)) {
  1085.         $taskmgr = Start-Process -WindowStyle Hidden -FilePath taskmgr.exe -PassThru
  1086.         While (!($preferences)) {
  1087.             Start-Sleep -m 250
  1088.             $preferences = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -ErrorAction SilentlyContinue
  1089.         }
  1090.         Stop-Process $taskmgr
  1091.     }
  1092.     $preferences.Preferences[28] = 0
  1093.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -Type Binary -Value $preferences.Preferences
  1094. }
  1095.  
  1096. # Hide Task Manager details
  1097. Function HideTaskManagerDetails {
  1098.     Write-Host "Hiding task manager details..."
  1099.     $preferences = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -ErrorAction SilentlyContinue
  1100.     If ($preferences) {
  1101.         $preferences.Preferences[28] = 1
  1102.         Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -Type Binary -Value $preferences.Preferences
  1103.     }
  1104. }
  1105.  
  1106. # Show file operations details
  1107. Function ShowFileOperationsDetails {
  1108.     Write-Host "Showing file operations details..."
  1109.     If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager")) {
  1110.         New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager" | Out-Null
  1111.     }
  1112.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager" -Name "EnthusiastMode" -Type DWord -Value 1
  1113. }
  1114.  
  1115. # Hide file operations details
  1116. Function HideFileOperationsDetails {
  1117.     Write-Host "Hiding file operations details..."
  1118.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager" -Name "EnthusiastMode" -ErrorAction SilentlyContinue
  1119. }
  1120.  
  1121. # Enable file delete confirmation dialog
  1122. Function EnableFileDeleteConfirm {
  1123.     Write-Host "Enabling file delete confirmation dialog..."
  1124.     If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer")) {
  1125.         New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" | Out-Null
  1126.     }
  1127.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "ConfirmFileDelete" -Type DWord -Value 1
  1128. }
  1129.  
  1130. # Disable file delete confirmation dialog
  1131. Function DisableFileDeleteConfirm {
  1132.     Write-Host "Disabling file delete confirmation dialog..."
  1133.     Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "ConfirmFileDelete" -ErrorAction SilentlyContinue
  1134. }
  1135.  
  1136. # Hide Taskbar Search button / box
  1137. Function HideTaskbarSearchBox {
  1138.     Write-Host "Hiding Taskbar Search box / button..."
  1139.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" -Name "SearchboxTaskbarMode" -Type DWord -Value 0
  1140. }
  1141.  
  1142. # Show Taskbar Search button / box
  1143. Function ShowTaskbarSearchBox {
  1144.     Write-Host "Showing Taskbar Search box / button..."
  1145.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" -Name "SearchboxTaskbarMode" -ErrorAction SilentlyContinue
  1146. }
  1147.  
  1148. # Hide Task View button
  1149. Function HideTaskView {
  1150.     Write-Host "Hiding Task View button..."
  1151.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Type DWord -Value 0
  1152. }
  1153.  
  1154. # Show Task View button
  1155. Function ShowTaskView {
  1156.     Write-Host "Showing Task View button..."
  1157.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -ErrorAction SilentlyContinue
  1158. }
  1159.  
  1160. # Show small icons in taskbar
  1161. Function ShowSmallTaskbarIcons {
  1162.     Write-Host "Showing small icons in taskbar..."
  1163.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarSmallIcons" -Type DWord -Value 1
  1164. }
  1165.  
  1166. # Show large icons in taskbar
  1167. Function ShowLargeTaskbarIcons {
  1168.     Write-Host "Showing large icons in taskbar..."
  1169.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarSmallIcons" -ErrorAction SilentlyContinue
  1170. }
  1171.  
  1172. # Show titles in taskbar
  1173. Function ShowTaskbarTitles {
  1174.     Write-Host "Showing titles in taskbar..."
  1175.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarGlomLevel" -Type DWord -Value 1
  1176. }
  1177.  
  1178. # Hide titles in taskbar
  1179. Function HideTaskbarTitles {
  1180.     Write-Host "Hiding titles in taskbar..."
  1181.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarGlomLevel" -ErrorAction SilentlyContinue
  1182. }
  1183.  
  1184. # Hide Taskbar People icon
  1185. Function HideTaskbarPeopleIcon {
  1186.     Write-Host "Hiding People icon..."
  1187.     If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People")) {
  1188.         New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" | Out-Null
  1189.     }
  1190.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name "PeopleBand" -Type DWord -Value 0
  1191. }
  1192.  
  1193. # Show Taskbar People icon
  1194. Function ShowTaskbarPeopleIcon {
  1195.     Write-Host "Showing People icon..."
  1196.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name "PeopleBand" -ErrorAction SilentlyContinue
  1197. }
  1198.  
  1199. # Show all tray icons
  1200. Function ShowTrayIcons {
  1201.     Write-Host "Showing all tray icons..."
  1202.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "EnableAutoTray" -Type DWord -Value 0
  1203. }
  1204.  
  1205. # Hide tray icons as needed
  1206. Function HideTrayIcons {
  1207.     Write-Host "Hiding tray icons..."
  1208.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "EnableAutoTray" -ErrorAction SilentlyContinue
  1209. }
  1210.  
  1211. # Show known file extensions
  1212. Function ShowKnownExtensions {
  1213.     Write-Host "Showing known file extensions..."
  1214.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideFileExt" -Type DWord -Value 0
  1215. }
  1216.  
  1217. # Hide known file extensions
  1218. Function HideKnownExtensions {
  1219.     Write-Host "Hiding known file extensions..."
  1220.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideFileExt" -Type DWord -Value 1
  1221. }
  1222.  
  1223. # Show hidden files
  1224. Function ShowHiddenFiles {
  1225.     Write-Host "Showing hidden files..."
  1226.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Hidden" -Type DWord -Value 1
  1227. }
  1228.  
  1229. # Hide hidden files
  1230. Function HideHiddenFiles {
  1231.     Write-Host "Hiding hidden files..."
  1232.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Hidden" -Type DWord -Value 2
  1233. }
  1234.  
  1235. # Hide sync provider notifications
  1236. Function HideSyncNotifications {
  1237.     Write-Host "Hiding sync provider notifications..."
  1238.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowSyncProviderNotifications" -Type DWord -Value 0
  1239. }
  1240.  
  1241. # Show sync provider notifications
  1242. Function ShowSyncNotifications {
  1243.     Write-Host "Showing sync provider notifications..."
  1244.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowSyncProviderNotifications" -Type DWord -Value 1
  1245. }
  1246.  
  1247. # Hide recently and frequently used item shortcuts in Explorer
  1248. Function HideRecentShortcuts {
  1249.     Write-Host "Hiding recent shortcuts..."
  1250.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "ShowRecent" -Type DWord -Value 0
  1251.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "ShowFrequent" -Type DWord -Value 0
  1252. }
  1253.  
  1254. # Show recently and frequently used item shortcuts in Explorer
  1255. Function ShowRecentShortcuts {
  1256.     Write-Host "Showing recent shortcuts..."
  1257.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "ShowRecent" -ErrorAction SilentlyContinue
  1258.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "ShowFrequent" -ErrorAction SilentlyContinue
  1259. }
  1260.  
  1261. # Change default Explorer view to This PC
  1262. Function SetExplorerThisPC {
  1263.     Write-Host "Changing default Explorer view to This PC..."
  1264.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "LaunchTo" -Type DWord -Value 1
  1265. }
  1266.  
  1267. # Change default Explorer view to Quick Access
  1268. Function SetExplorerQuickAccess {
  1269.     Write-Host "Changing default Explorer view to Quick Access..."
  1270.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "LaunchTo" -ErrorAction SilentlyContinue
  1271. }
  1272.  
  1273. # Show This PC shortcut on desktop
  1274. Function ShowThisPCOnDesktop {
  1275.     Write-Host "Showing This PC shortcut on desktop..."
  1276.     If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu")) {
  1277.         New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Force | Out-Null
  1278.     }
  1279.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Name "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" -Type DWord -Value 0
  1280.     If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel")) {
  1281.         New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Force | Out-Null
  1282.     }
  1283.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" -Type DWord -Value 0
  1284. }
  1285.  
  1286. # Hide This PC shortcut from desktop
  1287. Function HideThisPCFromDesktop {
  1288.     Write-Host "Hiding This PC shortcut from desktop..."
  1289.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Name "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" -ErrorAction SilentlyContinue
  1290.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" -ErrorAction SilentlyContinue
  1291. }
  1292.  
  1293. # Show User Folder shortcut on desktop
  1294. Function ShowUserFolderOnDesktop {
  1295.     Write-Host "Showing User Folder shortcut on desktop..."
  1296.     If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu")) {
  1297.         New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Force | Out-Null
  1298.     }
  1299.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Name "{59031a47-3f72-44a7-89c5-5595fe6b30ee}" -Type DWord -Value 0
  1300.     If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel")) {
  1301.         New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Force | Out-Null
  1302.     }
  1303.     Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name "{59031a47-3f72-44a7-89c5-5595fe6b30ee}" -Type DWord -Value 0
  1304. }
  1305.  
  1306. # Hide User Folder shortcut from desktop
  1307. Function HideUserFolderFromDesktop {
  1308.     Write-Host "Hiding User Folder shortcut from desktop..."
  1309.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Name "{59031a47-3f72-44a7-89c5-5595fe6b30ee}" -ErrorAction SilentlyContinue
  1310.     Remove-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name "{59031a47-3f72-44a7-89c5-5595fe6b30ee}" -ErrorAction SilentlyContinue
  1311. }
  1312.  
  1313. # Hide Desktop icon from This PC
  1314. Function HideDesktopFromThisPC {
  1315.     Write-Host "Hiding Desktop icon from This PC..."
  1316.     Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}" -Recurse -ErrorAction SilentlyContinue
  1317. }
  1318.  
  1319. # Show Desktop icon in This PC
  1320. Function ShowDesktopInThisPC {
  1321.     Write-Host "Showing Desktop icon in This PC..."
  1322.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}")) {
  1323.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}" | Out-Null
  1324.     }
  1325. }
  1326.  
  1327. # Hide Documents icon from This PC
  1328. Function HideDocumentsFromThisPC {
  1329.     Write-Host "Hiding Documents icon from This PC..."
  1330.     Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{d3162b92-9365-467a-956b-92703aca08af}" -Recurse -ErrorAction SilentlyContinue
  1331.     Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A8CDFF1C-4878-43be-B5FD-F8091C1C60D0}" -Recurse -ErrorAction SilentlyContinue
  1332. }
  1333.  
  1334. # Show Documents icon in This PC
  1335. Function ShowDocumentsInThisPC {
  1336.     Write-Host "Showing Documents icon in This PC..."
  1337.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{d3162b92-9365-467a-956b-92703aca08af}")) {
  1338.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{d3162b92-9365-467a-956b-92703aca08af}" | Out-Null
  1339.     }
  1340.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A8CDFF1C-4878-43be-B5FD-F8091C1C60D0}")) {
  1341.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A8CDFF1C-4878-43be-B5FD-F8091C1C60D0}" | Out-Null
  1342.     }
  1343. }
  1344.  
  1345. # Hide Downloads icon from This PC
  1346. Function HideDownloadsFromThisPC {
  1347.     Write-Host "Hiding Downloads icon from This PC..."
  1348.     Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{088e3905-0323-4b02-9826-5d99428e115f}" -Recurse -ErrorAction SilentlyContinue
  1349.     Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{374DE290-123F-4565-9164-39C4925E467B}" -Recurse -ErrorAction SilentlyContinue
  1350. }
  1351.  
  1352. # Show Downloads icon in This PC
  1353. Function ShowDownloadsInThisPC {
  1354.     Write-Host "Showing Downloads icon in This PC..."
  1355.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{088e3905-0323-4b02-9826-5d99428e115f}")) {
  1356.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{088e3905-0323-4b02-9826-5d99428e115f}" | Out-Null
  1357.     }
  1358.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{374DE290-123F-4565-9164-39C4925E467B}")) {
  1359.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{374DE290-123F-4565-9164-39C4925E467B}" | Out-Null
  1360.     }
  1361. }
  1362.  
  1363. # Hide Music icon from This PC
  1364. Function HideMusicFromThisPC {
  1365.     Write-Host "Hiding Music icon from This PC..."
  1366.     Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3dfdf296-dbec-4fb4-81d1-6a3438bcf4de}" -Recurse -ErrorAction SilentlyContinue
  1367.     Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{1CF1260C-4DD0-4ebb-811F-33C572699FDE}" -Recurse -ErrorAction SilentlyContinue
  1368. }
  1369.  
  1370. # Show Music icon in This PC
  1371. Function ShowMusicInThisPC {
  1372.     Write-Host "Showing Music icon in This PC..."
  1373.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3dfdf296-dbec-4fb4-81d1-6a3438bcf4de}")) {
  1374.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3dfdf296-dbec-4fb4-81d1-6a3438bcf4de}" | Out-Null
  1375.     }
  1376.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{1CF1260C-4DD0-4ebb-811F-33C572699FDE}")) {
  1377.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{1CF1260C-4DD0-4ebb-811F-33C572699FDE}" | Out-Null
  1378.     }
  1379. }
  1380.  
  1381. # Hide Pictures icon from This PC
  1382. Function HidePicturesFromThisPC {
  1383.     Write-Host "Hiding Pictures icon from This PC..."
  1384.     Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{24ad3ad4-a569-4530-98e1-ab02f9417aa8}" -Recurse -ErrorAction SilentlyContinue
  1385.     Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3ADD1653-EB32-4cb0-BBD7-DFA0ABB5ACCA}" -Recurse -ErrorAction SilentlyContinue
  1386. }
  1387.  
  1388. # Show Pictures icon in This PC
  1389. Function ShowPicturesInThisPC {
  1390.     Write-Host "Showing Pictures icon in This PC..."
  1391.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{24ad3ad4-a569-4530-98e1-ab02f9417aa8}")) {
  1392.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{24ad3ad4-a569-4530-98e1-ab02f9417aa8}" | Out-Null
  1393.     }
  1394.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3ADD1653-EB32-4cb0-BBD7-DFA0ABB5ACCA}")) {
  1395.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3ADD1653-EB32-4cb0-BBD7-DFA0ABB5ACCA}" | Out-Null
  1396.     }
  1397. }
  1398.  
  1399. # Hide Videos icon from This PC
  1400. Function HideVideosFromThisPC {
  1401.     Write-Host "Hiding Videos icon from This PC..."
  1402.     Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}" -Recurse -ErrorAction SilentlyContinue
  1403.     Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A0953C92-50DC-43bf-BE83-3742FED03C9C}" -Recurse -ErrorAction SilentlyContinue
  1404. }
  1405.  
  1406. # Show Videos icon in This PC
  1407. Function ShowVideosInThisPC {
  1408.     Write-Host "Showing Videos icon in This PC..."
  1409.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}")) {
  1410.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}" | Out-Null
  1411.     }
  1412.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A0953C92-50DC-43bf-BE83-3742FED03C9C}")) {
  1413.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A0953C92-50DC-43bf-BE83-3742FED03C9C}" | Out-Null
  1414.     }
  1415. }
  1416.  
  1417. # Hide 3D Objects icon from This PC
  1418. Function Hide3DObjectsFromThisPC {
  1419.     Write-Host "Hiding 3D Objects icon from This PC..."
  1420.     Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" -Recurse -ErrorAction SilentlyContinue
  1421. }
  1422.  
  1423. # Show 3D Objects icon in This PC
  1424. Function Show3DObjectsInThisPC {
  1425.     Write-Host "Showing 3D Objects icon in This PC..."
  1426.     If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}")) {
  1427.         New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" | Out-Null
  1428.     }
  1429. }
  1430.  
  1431. # Adjusts visual effects for performance - Disables animations, transparency etc. but leaves font smoothing and miniatures enabled
  1432. Function SetVisualFXPerformance {
  1433.     Write-Host "Adjusting visual effects for performance..."
  1434.     Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "DragFullWindows" -Type String -Value 0
  1435.     Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "MenuShowDelay" -Type String -Value 0
  1436.     Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "UserPreferencesMask" -Type Binary -Value ([byte[]](0x90,0x12,0x03,0x80,0x10,0x00,0x00,0x00))
  1437.     Set-ItemProperty -Path "HKCU:\Control Panel\Desktop\WindowMetrics" -Name "MinAnimate" -Type String -Value 0
  1438.     Set-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name "KeyboardDelay" -Type DWord -Value 0
  1439.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewAlphaSelect" -Type DWord -Value 0
  1440.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewShadow" -Type DWord -Value 0
  1441.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAnimations" -Type DWord -Value 0
  1442.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" -Name "VisualFXSetting" -Type DWord -Value 3
  1443.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\DWM" -Name "EnableAeroPeek" -Type DWord -Value 0
  1444. }
  1445.  
  1446. # Adjusts visual effects for appearance
  1447. Function SetVisualFXAppearance {
  1448.     Write-Host "Adjusting visual effects for appearance..."
  1449.     Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "DragFullWindows" -Type String -Value 1
  1450.     Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "MenuShowDelay" -Type String -Value 400
  1451.     Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "UserPreferencesMask" -Type Binary -Value ([byte[]](0x9E,0x1E,0x07,0x80,0x12,0x00,0x00,0x00))
  1452.     Set-ItemProperty -Path "HKCU:\Control Panel\Desktop\WindowMetrics" -Name "MinAnimate" -Type String -Value 1
  1453.     Set-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name "KeyboardDelay" -Type DWord -Value 1
  1454.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewAlphaSelect" -Type DWord -Value 1
  1455.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewShadow" -Type DWord -Value 1
  1456.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAnimations" -Type DWord -Value 1
  1457.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" -Name "VisualFXSetting" -Type DWord -Value 3
  1458.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\DWM" -Name "EnableAeroPeek" -Type DWord -Value 1
  1459. }
  1460.  
  1461. # Disable thumbnails, show only file extension icons
  1462. Function DisableThumbnails {
  1463.     Write-Host "Disabling thumbnails..."
  1464.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "IconsOnly" -Type DWord -Value 1
  1465. }
  1466.  
  1467. # Enable thumbnails
  1468. Function EnableThumbnails {
  1469.     Write-Host "Enabling thumbnails..."
  1470.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "IconsOnly" -Type DWord -Value 0
  1471. }
  1472.  
  1473. # Disable creation of Thumbs.db thumbnail cache files
  1474. Function DisableThumbsDB {
  1475.     Write-Host "Disabling creation of Thumbs.db..."
  1476.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "DisableThumbnailCache" -Type DWord -Value 1
  1477.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "DisableThumbsDBOnNetworkFolders" -Type DWord -Value 1
  1478. }
  1479.  
  1480. # Enable creation of Thumbs.db thumbnail cache files
  1481. Function EnableThumbsDB {
  1482.     Write-Host "Enable creation of Thumbs.db..."
  1483.     Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "DisableThumbnailCache" -ErrorAction SilentlyContinue
  1484.     Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "DisableThumbsDBOnNetworkFolders" -ErrorAction SilentlyContinue
  1485. }
  1486.  
  1487. # Add secondary en-US keyboard
  1488. Function AddENKeyboard {
  1489.     Write-Host "Adding secondary en-US keyboard..."
  1490.     $langs = Get-WinUserLanguageList
  1491.     $langs.Add("en-US")
  1492.     Set-WinUserLanguageList $langs -Force
  1493. }
  1494.  
  1495. # Remove secondary en-US keyboard
  1496. Function RemoveENKeyboard {
  1497.     Write-Host "Removing secondary en-US keyboard..."
  1498.     $langs = Get-WinUserLanguageList
  1499.     Set-WinUserLanguageList ($langs | ? {$_.LanguageTag -ne "en-US"}) -Force
  1500. }
  1501.  
  1502. # Enable NumLock after startup
  1503. Function EnableNumlock {
  1504.     Write-Host "Enabling NumLock after startup..."
  1505.     If (!(Test-Path "HKU:")) {
  1506.         New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS | Out-Null
  1507.     }
  1508.     Set-ItemProperty -Path "HKU:\.DEFAULT\Control Panel\Keyboard" -Name "InitialKeyboardIndicators" -Type DWord -Value 2147483650
  1509.     Add-Type -AssemblyName System.Windows.Forms
  1510.     If (!([System.Windows.Forms.Control]::IsKeyLocked('NumLock'))) {
  1511.         $wsh = New-Object -ComObject WScript.Shell
  1512.         $wsh.SendKeys('{NUMLOCK}')
  1513.     }
  1514. }
  1515.  
  1516. # Disable NumLock after startup
  1517. Function DisableNumlock {
  1518.     Write-Host "Disabling NumLock after startup..."
  1519.     If (!(Test-Path "HKU:")) {
  1520.         New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS | Out-Null
  1521.     }
  1522.     Set-ItemProperty -Path "HKU:\.DEFAULT\Control Panel\Keyboard" -Name "InitialKeyboardIndicators" -Type DWord -Value 2147483648
  1523.     Add-Type -AssemblyName System.Windows.Forms
  1524.     If ([System.Windows.Forms.Control]::IsKeyLocked('NumLock')) {
  1525.         $wsh = New-Object -ComObject WScript.Shell
  1526.         $wsh.SendKeys('{NUMLOCK}')
  1527.     }
  1528. }
  1529.  
  1530.  
  1531.  
  1532. ##########
  1533. # Application Tweaks
  1534. ##########
  1535.  
  1536. # Disable OneDrive
  1537. Function DisableOneDrive {
  1538.     Write-Host "Disabling OneDrive..."
  1539.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive")) {
  1540.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" | Out-Null
  1541.     }
  1542.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Name "DisableFileSyncNGSC" -Type DWord -Value 1
  1543. }
  1544.  
  1545. # Enable OneDrive
  1546. Function EnableOneDrive {
  1547.     Write-Host "Enabling OneDrive..."
  1548.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Name "DisableFileSyncNGSC" -ErrorAction SilentlyContinue
  1549. }
  1550.  
  1551. # Uninstall OneDrive - Not applicable to Server
  1552. Function UninstallOneDrive {
  1553.     Write-Host "Uninstalling OneDrive..."
  1554.     Stop-Process -Name OneDrive -ErrorAction SilentlyContinue
  1555.     Start-Sleep -s 3
  1556.     $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
  1557.     If (!(Test-Path $onedrive)) {
  1558.         $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe"
  1559.     }
  1560.     Start-Process $onedrive "/uninstall" -NoNewWindow -Wait
  1561.     Start-Sleep -s 3
  1562.     Stop-Process -Name explorer -ErrorAction SilentlyContinue
  1563.     Start-Sleep -s 3
  1564.     Remove-Item "$env:USERPROFILE\OneDrive" -Force -Recurse -ErrorAction SilentlyContinue
  1565.     Remove-Item "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse -ErrorAction SilentlyContinue
  1566.     Remove-Item "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse -ErrorAction SilentlyContinue
  1567.     Remove-Item "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse -ErrorAction SilentlyContinue
  1568.     If (!(Test-Path "HKCR:")) {
  1569.         New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null
  1570.     }
  1571.     Remove-Item -Path "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" -Recurse -ErrorAction SilentlyContinue
  1572.     Remove-Item -Path "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" -Recurse -ErrorAction SilentlyContinue
  1573. }
  1574.  
  1575. # Install OneDrive - Not applicable to Server
  1576. Function InstallOneDrive {
  1577.     Write-Host "Installing OneDrive..."
  1578.     $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe"
  1579.     If (!(Test-Path $onedrive)) {
  1580.         $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe"
  1581.     }
  1582.     Start-Process $onedrive -NoNewWindow
  1583. }
  1584.  
  1585. # Uninstall default Microsoft applications
  1586. Function UninstallMsftBloat {
  1587.     Write-Host "Uninstalling default Microsoft applications..."
  1588.     Get-AppxPackage "Microsoft.3DBuilder" | Remove-AppxPackage
  1589.     Get-AppxPackage "Microsoft.BingFinance" | Remove-AppxPackage
  1590.     Get-AppxPackage "Microsoft.BingNews" | Remove-AppxPackage
  1591.     Get-AppxPackage "Microsoft.BingSports" | Remove-AppxPackage
  1592.     Get-AppxPackage "Microsoft.BingWeather" | Remove-AppxPackage
  1593.     Get-AppxPackage "Microsoft.Getstarted" | Remove-AppxPackage
  1594.     Get-AppxPackage "Microsoft.MicrosoftOfficeHub" | Remove-AppxPackage
  1595.     Get-AppxPackage "Microsoft.MicrosoftSolitaireCollection" | Remove-AppxPackage
  1596.     Get-AppxPackage "Microsoft.Office.OneNote" | Remove-AppxPackage
  1597.     Get-AppxPackage "Microsoft.People" | Remove-AppxPackage
  1598.     Get-AppxPackage "Microsoft.SkypeApp" | Remove-AppxPackage
  1599.     Get-AppxPackage "Microsoft.Windows.Photos" | Remove-AppxPackage
  1600.     Get-AppxPackage "Microsoft.WindowsAlarms" | Remove-AppxPackage
  1601.     Get-AppxPackage "Microsoft.WindowsCamera" | Remove-AppxPackage
  1602.     Get-AppxPackage "microsoft.windowscommunicationsapps" | Remove-AppxPackage
  1603.     Get-AppxPackage "Microsoft.WindowsMaps" | Remove-AppxPackage
  1604.     Get-AppxPackage "Microsoft.WindowsPhone" | Remove-AppxPackage
  1605.     Get-AppxPackage "Microsoft.WindowsSoundRecorder" | Remove-AppxPackage
  1606.     Get-AppxPackage "Microsoft.ZuneMusic" | Remove-AppxPackage
  1607.     Get-AppxPackage "Microsoft.ZuneVideo" | Remove-AppxPackage
  1608.     Get-AppxPackage "Microsoft.AppConnector" | Remove-AppxPackage
  1609.     Get-AppxPackage "Microsoft.ConnectivityStore" | Remove-AppxPackage
  1610.     Get-AppxPackage "Microsoft.Office.Sway" | Remove-AppxPackage
  1611.     Get-AppxPackage "Microsoft.Messaging" | Remove-AppxPackage
  1612.     Get-AppxPackage "Microsoft.CommsPhone" | Remove-AppxPackage
  1613.     Get-AppxPackage "Microsoft.MicrosoftStickyNotes" | Remove-AppxPackage
  1614.     Get-AppxPackage "Microsoft.OneConnect" | Remove-AppxPackage
  1615.     Get-AppxPackage "Microsoft.WindowsFeedbackHub" | Remove-AppxPackage
  1616.     Get-AppxPackage "Microsoft.MinecraftUWP" | Remove-AppxPackage
  1617.     Get-AppxPackage "Microsoft.MicrosoftPowerBIForWindows" | Remove-AppxPackage
  1618.     Get-AppxPackage "Microsoft.NetworkSpeedTest" | Remove-AppxPackage
  1619.     Get-AppxPackage "Microsoft.MSPaint" | Remove-AppxPackage
  1620.     Get-AppxPackage "Microsoft.Microsoft3DViewer" | Remove-AppxPackage
  1621.     Get-AppxPackage "Microsoft.RemoteDesktop" | Remove-AppxPackage
  1622.     Get-AppxPackage "Microsoft.Print3D" | Remove-AppxPackage
  1623. }
  1624.  
  1625. # Install default Microsoft applications
  1626. Function InstallMsftBloat {
  1627.     Write-Host "Installing default Microsoft applications..."
  1628.     Get-AppxPackage -AllUsers "Microsoft.3DBuilder" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1629.     Get-AppxPackage -AllUsers "Microsoft.BingFinance" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1630.     Get-AppxPackage -AllUsers "Microsoft.BingNews" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1631.     Get-AppxPackage -AllUsers "Microsoft.BingSports" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1632.     Get-AppxPackage -AllUsers "Microsoft.BingWeather" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1633.     Get-AppxPackage -AllUsers "Microsoft.Getstarted" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1634.     Get-AppxPackage -AllUsers "Microsoft.MicrosoftOfficeHub" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1635.     Get-AppxPackage -AllUsers "Microsoft.MicrosoftSolitaireCollection" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1636.     Get-AppxPackage -AllUsers "Microsoft.Office.OneNote" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1637.     Get-AppxPackage -AllUsers "Microsoft.People" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1638.     Get-AppxPackage -AllUsers "Microsoft.SkypeApp" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1639.     Get-AppxPackage -AllUsers "Microsoft.Windows.Photos" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1640.     Get-AppxPackage -AllUsers "Microsoft.WindowsAlarms" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1641.     Get-AppxPackage -AllUsers "Microsoft.WindowsCamera" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1642.     Get-AppxPackage -AllUsers "Microsoft.windowscommunicationsapps" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1643.     Get-AppxPackage -AllUsers "Microsoft.WindowsMaps" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1644.     Get-AppxPackage -AllUsers "Microsoft.WindowsPhone" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1645.     Get-AppxPackage -AllUsers "Microsoft.WindowsSoundRecorder" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1646.     Get-AppxPackage -AllUsers "Microsoft.ZuneMusic" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1647.     Get-AppxPackage -AllUsers "Microsoft.ZuneVideo" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1648.     Get-AppxPackage -AllUsers "Microsoft.AppConnector" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1649.     Get-AppxPackage -AllUsers "Microsoft.ConnectivityStore" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1650.     Get-AppxPackage -AllUsers "Microsoft.Office.Sway" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1651.     Get-AppxPackage -AllUsers "Microsoft.Messaging" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1652.     Get-AppxPackage -AllUsers "Microsoft.CommsPhone" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1653.     Get-AppxPackage -AllUsers "Microsoft.MicrosoftStickyNotes" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1654.     Get-AppxPackage -AllUsers "Microsoft.OneConnect" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1655.     Get-AppxPackage -AllUsers "Microsoft.WindowsFeedbackHub" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1656.     Get-AppxPackage -AllUsers "Microsoft.MinecraftUWP" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1657.     Get-AppxPackage -AllUsers "Microsoft.MicrosoftPowerBIForWindows" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1658.     Get-AppxPackage -AllUsers "Microsoft.NetworkSpeedTest" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1659.     Get-AppxPackage -AllUsers "Microsoft.MSPaint" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1660.     Get-AppxPackage -AllUsers "Microsoft.Microsoft3DViewer" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1661.     Get-AppxPackage -AllUsers "Microsoft.RemoteDesktop" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1662.     Get-AppxPackage -AllUsers "Microsoft.Print3D" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1663. }
  1664. # In case you have removed them for good, you can try to restore the files using installation medium as follows
  1665. # New-Item C:\Mnt -Type Directory | Out-Null
  1666. # dism /Mount-Image /ImageFile:D:\sources\install.wim /index:1 /ReadOnly /MountDir:C:\Mnt
  1667. # robocopy /S /SEC /R:0 "C:\Mnt\Program Files\WindowsApps" "C:\Program Files\WindowsApps"
  1668. # dism /Unmount-Image /Discard /MountDir:C:\Mnt
  1669. # Remove-Item -Path C:\Mnt -Recurse
  1670.  
  1671. # Uninstall default third party applications
  1672. function UninstallThirdPartyBloat {
  1673.     Write-Host "Uninstalling default third party applications..."
  1674.     Get-AppxPackage "9E2F88E3.Twitter" | Remove-AppxPackage
  1675.     Get-AppxPackage "king.com.CandyCrushSodaSaga" | Remove-AppxPackage
  1676.     Get-AppxPackage "4DF9E0F8.Netflix" | Remove-AppxPackage
  1677.     Get-AppxPackage "Drawboard.DrawboardPDF" | Remove-AppxPackage
  1678.     Get-AppxPackage "D52A8D61.FarmVille2CountryEscape" | Remove-AppxPackage
  1679.     Get-AppxPackage "GAMELOFTSA.Asphalt8Airborne" | Remove-AppxPackage
  1680.     Get-AppxPackage "flaregamesGmbH.RoyalRevolt2" | Remove-AppxPackage
  1681.     Get-AppxPackage "AdobeSystemsIncorporated.AdobePhotoshopExpress" | Remove-AppxPackage
  1682.     Get-AppxPackage "ActiproSoftwareLLC.562882FEEB491" | Remove-AppxPackage
  1683.     Get-AppxPackage "D5EA27B7.Duolingo-LearnLanguagesforFree" | Remove-AppxPackage
  1684.     Get-AppxPackage "Facebook.Facebook" | Remove-AppxPackage
  1685.     Get-AppxPackage "46928bounde.EclipseManager" | Remove-AppxPackage
  1686.     Get-AppxPackage "A278AB0D.MarchofEmpires" | Remove-AppxPackage
  1687.     Get-AppxPackage "KeeperSecurityInc.Keeper" | Remove-AppxPackage
  1688.     Get-AppxPackage "king.com.BubbleWitch3Saga" | Remove-AppxPackage
  1689.     Get-AppxPackage "89006A2E.AutodeskSketchBook" | Remove-AppxPackage
  1690.     Get-AppxPackage "CAF9E577.Plex" | Remove-AppxPackage
  1691.     Get-AppxPackage "A278AB0D.DisneyMagicKingdoms" | Remove-AppxPackage
  1692.     Get-AppxPackage "828B5831.HiddenCityMysteryofShadows" | Remove-AppxPackage
  1693. }
  1694.  
  1695. # Install default third party applications
  1696. Function InstallThirdPartyBloat {
  1697.     Write-Host "Installing default third party applications..."
  1698.     Get-AppxPackage -AllUsers "9E2F88E3.Twitter" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1699.     Get-AppxPackage -AllUsers "king.com.CandyCrushSodaSaga" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1700.     Get-AppxPackage -AllUsers "4DF9E0F8.Netflix" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1701.     Get-AppxPackage -AllUsers "Drawboard.DrawboardPDF" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1702.     Get-AppxPackage -AllUsers "D52A8D61.FarmVille2CountryEscape" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1703.     Get-AppxPackage -AllUsers "GAMELOFTSA.Asphalt8Airborne" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1704.     Get-AppxPackage -AllUsers "flaregamesGmbH.RoyalRevolt2" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1705.     Get-AppxPackage -AllUsers "AdobeSystemsIncorporated.AdobePhotoshopExpress" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1706.     Get-AppxPackage -AllUsers "ActiproSoftwareLLC.562882FEEB491" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1707.     Get-AppxPackage -AllUsers "D5EA27B7.Duolingo-LearnLanguagesforFree" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1708.     Get-AppxPackage -AllUsers "Facebook.Facebook" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1709.     Get-AppxPackage -AllUsers "46928bounde.EclipseManager" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1710.     Get-AppxPackage -AllUsers "A278AB0D.MarchofEmpires" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1711.     Get-AppxPackage -AllUsers "KeeperSecurityInc.Keeper" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1712.     Get-AppxPackage -AllUsers "king.com.BubbleWitch3Saga" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1713.     Get-AppxPackage -AllUsers "89006A2E.AutodeskSketchBook" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1714.     Get-AppxPackage -AllUsers "CAF9E577.Plex" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1715.     Get-AppxPackage -AllUsers "A278AB0D.DisneyMagicKingdoms" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1716.     Get-AppxPackage -AllUsers "828B5831.HiddenCityMysteryofShadows" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1717. }
  1718.  
  1719. # Uninstall Windows Store
  1720. Function UninstallWindowsStore {
  1721.     Write-Host "Uninstalling Windows Store..."
  1722.     Get-AppxPackage "Microsoft.DesktopAppInstaller" | Remove-AppxPackage
  1723.     Get-AppxPackage "Microsoft.WindowsStore" | Remove-AppxPackage
  1724. }
  1725.  
  1726. # Install Windows Store
  1727. Function InstallWindowsStore {
  1728.     Write-Host "Installing Windows Store..."
  1729.     Get-AppxPackage -AllUsers "Microsoft.DesktopAppInstaller" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1730.     Get-AppxPackage -AllUsers "Microsoft.WindowsStore" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1731. }
  1732.  
  1733. # Disable Xbox features
  1734. Function DisableXboxFeatures {
  1735.     Write-Host "Disabling Xbox features..."
  1736.     Get-AppxPackage "Microsoft.XboxApp" | Remove-AppxPackage
  1737.     Get-AppxPackage "Microsoft.XboxIdentityProvider" | Remove-AppxPackage
  1738.     Get-AppxPackage "Microsoft.XboxSpeechToTextOverlay" | Remove-AppxPackage
  1739.     Get-AppxPackage "Microsoft.XboxGameOverlay" | Remove-AppxPackage
  1740.     Get-AppxPackage "Microsoft.Xbox.TCUI" | Remove-AppxPackage
  1741.     Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_Enabled" -Type DWord -Value 0
  1742.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR")) {
  1743.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR" | Out-Null
  1744.     }
  1745.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR" -Name "AllowGameDVR" -Type DWord -Value 0
  1746. }
  1747.  
  1748. # Enable Xbox features
  1749. Function EnableXboxFeatures {
  1750.     Write-Host "Enabling Xbox features..."
  1751.     Get-AppxPackage -AllUsers "Microsoft.XboxApp" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1752.     Get-AppxPackage -AllUsers "Microsoft.XboxIdentityProvider" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1753.     Get-AppxPackage -AllUsers "Microsoft.XboxSpeechToTextOverlay" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1754.     Get-AppxPackage -AllUsers "Microsoft.XboxGameOverlay" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1755.     Get-AppxPackage -AllUsers "Microsoft.Xbox.TCUI" | ForEach {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"}
  1756.     Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_Enabled" -Type DWord -Value 1
  1757.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR" -Name "AllowGameDVR" -ErrorAction SilentlyContinue
  1758. }
  1759.  
  1760. # Disable built-in Adobe Flash in IE and Edge
  1761. Function DisableAdobeFlash {
  1762.     Write-Host "Disabling built-in Adobe Flash in IE and Edge..."
  1763.     If (!(Test-Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Addons")) {
  1764.         New-Item -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Addons" -Force | Out-Null
  1765.     }
  1766.     Set-ItemProperty -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Addons" -Name "FlashPlayerEnabled" -Type DWord -Value 0
  1767.     If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Ext\Settings\{D27CDB6E-AE6D-11CF-96B8-444553540000}")) {
  1768.         New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Ext\Settings\{D27CDB6E-AE6D-11CF-96B8-444553540000}" -Force | Out-Null
  1769.     }
  1770.     Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Ext\Settings\{D27CDB6E-AE6D-11CF-96B8-444553540000}" -Name "Flags" -Type DWord -Value 1
  1771. }
  1772.  
  1773. # Enable built-in Adobe Flash in IE and Edge
  1774. Function EnableAdobeFlash {
  1775.     Write-Host "Enabling built-in Adobe Flash in IE and Edge..."
  1776.     Remove-ItemProperty -Path "HKCU:\Software\Classes\Local Settings\Software\Microsoft\Windows\CurrentVersion\AppContainer\Storage\microsoft.microsoftedge_8wekyb3d8bbwe\MicrosoftEdge\Addons" -Name "FlashPlayerEnabled" -ErrorAction SilentlyContinue
  1777.     Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Ext\Settings\{D27CDB6E-AE6D-11CF-96B8-444553540000}" -Name "Flags" -ErrorAction SilentlyContinue
  1778. }
  1779.  
  1780. # Uninstall Windows Media Player
  1781. Function UninstallMediaPlayer {
  1782.     Write-Host "Uninstalling Windows Media Player..."
  1783.     Disable-WindowsOptionalFeature -Online -FeatureName "WindowsMediaPlayer" -NoRestart -WarningAction SilentlyContinue | Out-Null
  1784. }
  1785.  
  1786. # Install Windows Media Player
  1787. Function InstallMediaPlayer {
  1788.     Write-Host "Installing Windows Media Player..."
  1789.     Enable-WindowsOptionalFeature -Online -FeatureName "WindowsMediaPlayer" -NoRestart -WarningAction SilentlyContinue | Out-Null
  1790. }
  1791.  
  1792. # Uninstall Work Folders Client - Not applicable to Server
  1793. Function UninstallWorkFolders {
  1794.     Write-Host "Uninstalling Work Folders Client..."
  1795.     Disable-WindowsOptionalFeature -Online -FeatureName "WorkFolders-Client" -NoRestart -WarningAction SilentlyContinue | Out-Null
  1796. }
  1797.  
  1798. # Install Work Folders Client - Not applicable to Server
  1799. Function InstallWorkFolders {
  1800.     Write-Host "Installing Work Folders Client..."
  1801.     Enable-WindowsOptionalFeature -Online -FeatureName "WorkFolders-Client" -NoRestart -WarningAction SilentlyContinue | Out-Null
  1802. }
  1803.  
  1804. # Install Linux Subsystem - Applicable to 1607 or newer, not applicable to Server yet
  1805. Function InstallLinuxSubsystem {
  1806.     Write-Host "Installing Linux Subsystem..."
  1807.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowDevelopmentWithoutDevLicense" -Type DWord -Value 1
  1808.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowAllTrustedApps" -Type DWord -Value 1
  1809.     Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -NoRestart -WarningAction SilentlyContinue | Out-Null
  1810. }
  1811.  
  1812. # Uninstall Linux Subsystem - Applicable to 1607 or newer, not applicable to Server yet
  1813. Function UninstallLinuxSubsystem {
  1814.     Write-Host "Uninstalling Linux Subsystem..."
  1815.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowDevelopmentWithoutDevLicense" -Type DWord -Value 0
  1816.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowAllTrustedApps" -Type DWord -Value 0
  1817.     Disable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -NoRestart -WarningAction SilentlyContinue | Out-Null
  1818. }
  1819.  
  1820. # Install Hyper-V - Not applicable to Home
  1821. Function InstallHyperV {
  1822.     Write-Host "Installing Hyper-V..."
  1823.     If ((Get-WmiObject -Class "Win32_OperatingSystem").Caption -like "*Server*") {
  1824.         Install-WindowsFeature -Name "Hyper-V" -IncludeManagementTools -WarningAction SilentlyContinue | Out-Null
  1825.     } Else {
  1826.         Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-All" -NoRestart -WarningAction SilentlyContinue | Out-Null
  1827.     }
  1828. }
  1829.  
  1830. # Uninstall Hyper-V - Not applicable to Home
  1831. Function UninstallHyperV {
  1832.     Write-Host "Uninstalling Hyper-V..."
  1833.     If ((Get-WmiObject -Class "Win32_OperatingSystem").Caption -like "*Server*") {
  1834.         Uninstall-WindowsFeature -Name "Hyper-V" -IncludeManagementTools -WarningAction SilentlyContinue | Out-Null
  1835.     } Else {
  1836.         Disable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-All" -NoRestart -WarningAction SilentlyContinue | Out-Null
  1837.     }
  1838. }
  1839.  
  1840. # Set Photo Viewer association for bmp, gif, jpg, png and tif
  1841. Function SetPhotoViewerAssociation {
  1842.     Write-Host "Setting Photo Viewer association for bmp, gif, jpg, png and tif..."
  1843.     If (!(Test-Path "HKCR:")) {
  1844.         New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null
  1845.     }
  1846.     ForEach ($type in @("Paint.Picture", "giffile", "jpegfile", "pngfile")) {
  1847.         New-Item -Path $("HKCR:\$type\shell\open") -Force | Out-Null
  1848.         New-Item -Path $("HKCR:\$type\shell\open\command") | Out-Null
  1849.         Set-ItemProperty -Path $("HKCR:\$type\shell\open") -Name "MuiVerb" -Type ExpandString -Value "@%ProgramFiles%\Windows Photo Viewer\photoviewer.dll,-3043"
  1850.         Set-ItemProperty -Path $("HKCR:\$type\shell\open\command") -Name "(Default)" -Type ExpandString -Value "%SystemRoot%\System32\rundll32.exe `"%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll`", ImageView_Fullscreen %1"
  1851.     }
  1852. }
  1853.  
  1854. # Unset Photo Viewer association for bmp, gif, jpg, png and tif
  1855. Function UnsetPhotoViewerAssociation {
  1856.     Write-Host "Unsetting Photo Viewer association for bmp, gif, jpg, png and tif..."
  1857.     If (!(Test-Path "HKCR:")) {
  1858.         New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null
  1859.     }
  1860.     Remove-Item -Path "HKCR:\Paint.Picture\shell\open" -Recurse -ErrorAction SilentlyContinue
  1861.     Remove-ItemProperty -Path "HKCR:\giffile\shell\open" -Name "MuiVerb" -ErrorAction SilentlyContinue
  1862.     Set-ItemProperty -Path "HKCR:\giffile\shell\open" -Name "CommandId" -Type String -Value "IE.File"
  1863.     Set-ItemProperty -Path "HKCR:\giffile\shell\open\command" -Name "(Default)" -Type String -Value "`"$env:SystemDrive\Program Files\Internet Explorer\iexplore.exe`" %1"
  1864.     Set-ItemProperty -Path "HKCR:\giffile\shell\open\command" -Name "DelegateExecute" -Type String -Value "{17FE9752-0B5A-4665-84CD-569794602F5C}"
  1865.     Remove-Item -Path "HKCR:\jpegfile\shell\open" -Recurse -ErrorAction SilentlyContinue
  1866.     Remove-Item -Path "HKCR:\pngfile\shell\open" -Recurse -ErrorAction SilentlyContinue
  1867. }
  1868.  
  1869. # Add Photo Viewer to "Open with..."
  1870. Function AddPhotoViewerOpenWith {
  1871.     Write-Host "Adding Photo Viewer to `"Open with...`""
  1872.     If (!(Test-Path "HKCR:")) {
  1873.         New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null
  1874.     }
  1875.     New-Item -Path "HKCR:\Applications\photoviewer.dll\shell\open\command" -Force | Out-Null
  1876.     New-Item -Path "HKCR:\Applications\photoviewer.dll\shell\open\DropTarget" -Force | Out-Null
  1877.     Set-ItemProperty -Path "HKCR:\Applications\photoviewer.dll\shell\open" -Name "MuiVerb" -Type String -Value "@photoviewer.dll,-3043"
  1878.     Set-ItemProperty -Path "HKCR:\Applications\photoviewer.dll\shell\open\command" -Name "(Default)" -Type ExpandString -Value "%SystemRoot%\System32\rundll32.exe `"%ProgramFiles%\Windows Photo Viewer\PhotoViewer.dll`", ImageView_Fullscreen %1"
  1879.     Set-ItemProperty -Path "HKCR:\Applications\photoviewer.dll\shell\open\DropTarget" -Name "Clsid" -Type String -Value "{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}"
  1880. }
  1881.  
  1882. # Remove Photo Viewer from "Open with..."
  1883. Function RemovePhotoViewerOpenWith {
  1884.     Write-Host "Removing Photo Viewer from `"Open with...`""
  1885.     If (!(Test-Path "HKCR:")) {
  1886.         New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null
  1887.     }
  1888.     Remove-Item -Path "HKCR:\Applications\photoviewer.dll\shell\open" -Recurse -ErrorAction SilentlyContinue
  1889. }
  1890.  
  1891. # Disable search for app in store for unknown extensions
  1892. Function DisableSearchAppInStore {
  1893.     Write-Host "Disabling search for app in store for unknown extensions..."
  1894.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer")) {
  1895.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" | Out-Null
  1896.     }
  1897.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Name "NoUseStoreOpenWith" -Type DWord -Value 1
  1898. }
  1899.  
  1900. # Enable search for app in store for unknown extensions
  1901. Function EnableSearchAppInStore {
  1902.     Write-Host "Enabling search for app in store for unknown extensions..."
  1903.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Name "NoUseStoreOpenWith" -ErrorAction SilentlyContinue
  1904. }
  1905.  
  1906. # Disable 'How do you want to open this file?' prompt
  1907. Function DisableNewAppPrompt {
  1908.     Write-Host "Disabling 'How do you want to open this file?' prompt..."
  1909.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer")) {
  1910.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" | Out-Null
  1911.     }
  1912.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Name "NoNewAppAlert" -Type DWord -Value 1
  1913. }
  1914.  
  1915. # Enable 'How do you want to open this file?' prompt
  1916. Function EnableNewAppPrompt {
  1917.     Write-Host "Enabling 'How do you want to open this file?' prompt..."
  1918.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Name "NoNewAppAlert" -ErrorAction SilentlyContinue
  1919. }
  1920.  
  1921. # Enable F8 boot menu options
  1922. Function EnableF8BootMenu {
  1923.     Write-Host "Enabling F8 boot menu options..."
  1924.     bcdedit /set `{current`} bootmenupolicy Legacy | Out-Null
  1925. }
  1926.  
  1927. # Disable F8 boot menu options
  1928. Function DisableF8BootMenu {
  1929.     Write-Host "Disabling F8 boot menu options..."
  1930.     bcdedit /set `{current`} bootmenupolicy Standard | Out-Null
  1931. }
  1932.  
  1933. # Set Data Execution Prevention (DEP) policy to OptOut
  1934. Function SetDEPOptOut {
  1935.     Write-Host "Setting Data Execution Prevention (DEP) policy to OptOut..."
  1936.     bcdedit /set `{current`} nx OptOut | Out-Null
  1937. }
  1938.  
  1939. # Set Data Execution Prevention (DEP) policy to OptIn
  1940. Function SetDEPOptIn {
  1941.     Write-Host "Setting Data Execution Prevention (DEP) policy to OptIn..."
  1942.     bcdedit /set `{current`} nx OptIn | Out-Null
  1943. }
  1944.  
  1945.  
  1946.  
  1947. ##########
  1948. # Server specific Tweaks
  1949. ##########
  1950.  
  1951. # Hide Server Manager after login
  1952. Function HideServerManagerOnLogin {
  1953.     Write-Host "Hiding Server Manager after login..."
  1954.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Server\ServerManager")) {
  1955.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Server\ServerManager" -Force | Out-Null
  1956.     }
  1957.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Server\ServerManager" -Name "DoNotOpenAtLogon" -Type DWord -Value 1
  1958. }
  1959.  
  1960. # Hide Server Manager after login
  1961. Function ShowServerManagerOnLogin {
  1962.     Write-Host "Showing Server Manager after login..."
  1963.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Server\ServerManager" -Name "DoNotOpenAtLogon" -ErrorAction SilentlyContinue
  1964. }
  1965.  
  1966. # Disable Shutdown Event Tracker
  1967. Function DisableShutdownTracker {
  1968.     Write-Host "Disabling Shutdown Event Tracker..."
  1969.     If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Reliability")) {
  1970.         New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Reliability" -Force | Out-Null
  1971.     }
  1972.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Reliability" -Name "ShutdownReasonOn" -Type DWord -Value 0
  1973. }
  1974.  
  1975. # Enable Shutdown Event Tracker
  1976. Function EnableShutdownTracker {
  1977.     Write-Host "Enabling Shutdown Event Tracker..."
  1978.     Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Reliability" -Name "ShutdownReasonOn" -ErrorAction SilentlyContinue
  1979. }
  1980.  
  1981. # Disable password complexity and maximum age requirements
  1982. Function DisablePasswordPolicy {
  1983.     Write-Host "Disabling password complexity and maximum age requirements..."
  1984.     $tmpfile = New-TemporaryFile
  1985.     secedit /export /cfg $tmpfile /quiet
  1986.     (Get-Content $tmpfile).Replace("PasswordComplexity = 1", "PasswordComplexity = 0").Replace("MaximumPasswordAge = 42", "MaximumPasswordAge = -1") | Out-File $tmpfile
  1987.     secedit /configure /db "$env:SYSTEMROOT\security\database\local.sdb" /cfg $tmpfile /areas SECURITYPOLICY | Out-Null
  1988.     Remove-Item -Path $tmpfile
  1989. }
  1990.  
  1991. # Enable password complexity and maximum age requirements
  1992. Function EnablePasswordPolicy {
  1993.     Write-Host "Enabling password complexity and maximum age requirements..."
  1994.     $tmpfile = New-TemporaryFile
  1995.     secedit /export /cfg $tmpfile /quiet
  1996.     (Get-Content $tmpfile).Replace("PasswordComplexity = 0", "PasswordComplexity = 1").Replace("MaximumPasswordAge = -1", "MaximumPasswordAge = 42") | Out-File $tmpfile
  1997.     secedit /configure /db "$env:SYSTEMROOT\security\database\local.sdb" /cfg $tmpfile /areas SECURITYPOLICY | Out-Null
  1998.     Remove-Item -Path $tmpfile
  1999. }
  2000.  
  2001. # Disable Ctrl+Alt+Del requirement before login
  2002. Function DisableCtrlAltDelLogin {
  2003.     Write-Host "Disabling Ctrl+Alt+Del requirement before login..."
  2004.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "DisableCAD" -Type DWord -Value 1
  2005. }
  2006.  
  2007. # Enable Ctrl+Alt+Del requirement before login
  2008. Function EnableCtrlAltDelLogin {
  2009.     Write-Host "Enabling Ctrl+Alt+Del requirement before login..."
  2010.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "DisableCAD" -Type DWord -Value 0
  2011. }
  2012.  
  2013. # Disable Internet Explorer Enhanced Security Configuration (IE ESC)
  2014. Function DisableIEEnhancedSecurity {
  2015.     Write-Host "Disabling Internet Explorer Enhanced Security Configuration (IE ESC)..."
  2016.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" -Name "IsInstalled" -Type DWord -Value 0
  2017.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" -Name "IsInstalled" -Type DWord -Value 0
  2018. }
  2019.  
  2020. # Enable Internet Explorer Enhanced Security Configuration (IE ESC)
  2021. Function EnableIEEnhancedSecurity {
  2022.     Write-Host "Enabling Internet Explorer Enhanced Security Configuration (IE ESC)..."
  2023.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" -Name "IsInstalled" -Type DWord -Value 1
  2024.     Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" -Name "IsInstalled" -Type DWord -Value 1
  2025. }
  2026.  
  2027. ##########
  2028. # BlackDragonBE Tweaks
  2029. ##########
  2030. Function DisableExtraServices {
  2031.     Write-Host "Disabling extra services (BlackDragonBE)..."
  2032.  
  2033.     $services = @(
  2034.         "diagnosticshub.standardcollector.service"  # Microsoft (R) Diagnostics Hub Standard Collector Service
  2035.         "MapsBroker"                                # Downloaded Maps Manager
  2036.         "NetTcpPortSharing"                         # Net.Tcp Port Sharing Service
  2037.         "TrkWks"                                    # Distributed Link Tracking Client
  2038.         "WbioSrvc"                                  # Windows Biometric Service
  2039.         "WMPNetworkSvc"                             # Windows Media Player Network Sharing Service
  2040.         "AppVClient"
  2041.         "RemoteRegistry"
  2042.         "CDPSvc"
  2043.         "shpamsvc"
  2044.         "SCardSvr"
  2045.         "UevAgentService"
  2046.         "PeerDistSvc"
  2047.         "lfsvc"
  2048.         "HvHost"
  2049.         "vmickvpexchange"
  2050.         "vmicguestinterface"
  2051.         "vmicshutdown"
  2052.         "vmicheartbeat"
  2053.         "vmicvmsession"
  2054.         "vmicrdv"
  2055.         "vmictimesync"
  2056.         "vmicvss"
  2057.         "irmon"
  2058.         "SharedAccess"
  2059.         "SmsRouter"
  2060.         "CscService"
  2061.         "SEMgrSvc"
  2062.         "PhoneSvc"
  2063.         "RpcLocator"
  2064.         "RetailDemo"
  2065.         "SensorDataService"
  2066.         "SensrSvc"
  2067.         "SensorService"
  2068.         "ScDeviceEnum"
  2069.         "SCPolicySvc"
  2070.         "SNMPTRAP"
  2071.         "WFDSConSvc"
  2072.         "FrameServer"
  2073.         "wisvc"
  2074.         "icssvc"
  2075.         "WwanSvc"
  2076.     )
  2077.  
  2078.     foreach ($service in $services) {
  2079.         if (Get-Service $service -ErrorAction SilentlyContinue)
  2080.         {
  2081.             Write-Host "Stopping and disabling $service"
  2082.             Stop-Service -Name $service
  2083.             Get-Service -Name $service | Set-Service -StartupType Disabled
  2084.         } else {
  2085.             Write-Host "Skipping $service (does not exist)"
  2086.         }
  2087.     }
  2088. }
  2089.  
  2090. # Download ninite and install the selected apps
  2091. Function DoNiniteInstall {
  2092.     Write-Host "Downloading Ninite ..."
  2093.    
  2094.     $ofs = '-'
  2095.     $niniteurl = "https://ninite.com/" + $niniteapps + "/ninite.exe"
  2096.     $output = "C:\Ninite.exe"
  2097.    
  2098.     Invoke-WebRequest $niniteurl -OutFile $output
  2099.     & $output
  2100.  
  2101.     Write-Host
  2102.     Read-Host "Press ENTER when all applications have been installed by Ninite"
  2103. }
  2104.  
  2105. # Delete Temp Files
  2106. Function DeleteTempFiles {
  2107.     Write-Host "Cleaning up temporary files..."
  2108.     $tempfolders = @("C:\Windows\Temp\*", "C:\Windows\Prefetch\*", "C:\Documents and Settings\*\Local Settings\temp\*", "C:\Users\*\Appdata\Local\Temp\*")
  2109.     Remove-Item $tempfolders -force -recurse 2>&1 | Out-Null
  2110. }
  2111.  
  2112. # Clean WinSXS folder (WARNING: this takes a while!)
  2113. Function CleanWinSXS {
  2114.     Write-Host "Cleaning WinSXS folder, this may take a while, please wait..."
  2115.     Dism.exe /online /Cleanup-Image /StartComponentCleanup
  2116. }
  2117.  
  2118. # Download O&O Shutup10
  2119. Function DownloadShutup10 {
  2120.     Write-Host "Downloading Shutup10 & putting it on C drive..."
  2121.     $url = "https://dl5.oo-software.com/files/ooshutup10/OOSU10.exe"
  2122.     $output = "C:\Shutup10.exe"
  2123.     Invoke-WebRequest $url -OutFile $output
  2124. }
  2125.  
  2126. # Remove startup delay (use with SSD)
  2127. Function DisableStartupDelay {
  2128.     Write-Host "Removing startup delay..."
  2129.     New-Item -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer' -Name Serialize -Force | Out-Null
  2130.     New-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Serialize' -Name StartupDelayInMSec  -PropertyType DWORD -Value 0 -Force | Out-Null
  2131. }
  2132.  
  2133. # Stop and disable Windows Search Service
  2134. Function DisableWindowsSearch {
  2135.     Write-Host "Stopping and disabling Windows Search Service..."
  2136.     Stop-Service "WSearch" -WarningAction SilentlyContinue
  2137.     Set-Service "WSearch" -StartupType Disabled
  2138. }
  2139.  
  2140. # Enable and start Windows Search Service
  2141. Function EnableWindowsSearch {
  2142.     Write-Host "Enabling and starting Windows Search Service..."
  2143.     Set-Service "WSearch" -StartupType Automatic
  2144.     Start-Service "WSearch" -WarningAction SilentlyContinue
  2145. }
  2146.  
  2147. # Stop and disable Microsoft Compatibility Appraiser
  2148. Function DisableCompatibilityAppraiser {
  2149.     Write-Host "Stopping and disabling Microsoft Compatibility Appraiser..."
  2150.  
  2151.     # Disable compattelrunner.exe launched by scheduled tasks
  2152.     'Microsoft Compatibility Appraiser',
  2153.     'ProgramDataUpdater' | ForEach-Object {
  2154.         Get-ScheduledTask -TaskName $_ -TaskPath '\Microsoft\Windows\Application Experience\' |
  2155.         Disable-ScheduledTask | Out-Null
  2156.     }
  2157.  
  2158.     del C:\ProgramData\Microsoft\Diagnosis\ETLLogs\AutoLogger\AutoLogger-Diagtrack-Listener.etl -ErrorAction SilentlyContinue
  2159.  
  2160.     # Disable the Autologger session at the next computer restart
  2161.     Set-AutologgerConfig -Name 'AutoLogger-Diagtrack-Listener' -Start 0
  2162. }
  2163.  
  2164. ##########
  2165. # GPD Win Specific Tweaks
  2166. ##########
  2167.  
  2168. # Disable Connected Standby (CSEnabled)
  2169. Function DisableConnectedStandby {
  2170.     Write-Host "Disabling Connected Standby..."
  2171.     Set-ItemProperty -Path "HKLM:\SYSTEM\\CurrentControlSet\Control\Power" -Name "CSEnabled" -Type DWord -Value 0
  2172. }
  2173.  
  2174. # Disable hibernation/sleep
  2175. Function DisableHibernation {
  2176.     Write-Host "Disabling hibernation..."
  2177.     Start-Process 'powercfg.exe' -Verb runAs -ArgumentList '/h off'
  2178. }
  2179.  
  2180. # Increase Desktop Icon Size
  2181. Function EnableBigDesktopIcons {
  2182.     Set-ItemProperty -path HKCU:\Software\Microsoft\Windows\Shell\Bags\1\Desktop -name IconSize -value 100
  2183. }
  2184.  
  2185. # Disables several unnecessary components
  2186. Function RemoveUnneededComponents {
  2187.     $components = @(
  2188.     'Printing-PrintToPDFServices-Features',
  2189.     'Printing-XPSServices-Features',
  2190.     'Xps-Foundation-Xps-Viewer',
  2191.     'WorkFolders-Client',
  2192.     'MediaPlayback',
  2193.     'SMB1Protocol',
  2194.     'WCF-Services45',
  2195.     'MSRDC-Infrastructure',
  2196.     'Internet-Explorer-Optional-amd64'
  2197.     )
  2198.  
  2199.     foreach ($component in $components) {
  2200.         Write-Host "Removing component: $component"
  2201.         disable-windowsoptionalfeature -online -featureName $component -NoRestart
  2202.     }
  2203. }
  2204.  
  2205. # Extra strict service disabling to squeeze out the most RAM & CPU out of the Win
  2206. Function DisableGPDWinServices {
  2207.     Write-Host "Disabling extra services (GPD Win)..."
  2208.  
  2209.     $services = @(
  2210.         "Spooler"                                   # Print Spooler
  2211.         "TabletInputService"                        # Touch Keyboard & Handwriting Panel Service: fixes RetroArch crashes
  2212.     )
  2213.  
  2214.     foreach ($service in $services) {
  2215.         if (Get-Service $service -ErrorAction SilentlyContinue)
  2216.         {
  2217.             Write-Host "Stopping and disabling $service"
  2218.             Stop-Service -Name $service
  2219.             Get-Service -Name $service | Set-Service -StartupType Disabled
  2220.         } else {
  2221.             Write-Host "Skipping $service (does not exist)"
  2222.         }
  2223.     }
  2224. }
  2225.  
  2226. ##########
  2227. # Auxiliary Functions
  2228. ##########
  2229.  
  2230. # Relaunch the script with administrator privileges
  2231. Function RequireAdmin {
  2232.     If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")) {
  2233.         Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" $PSCommandArgs" -WorkingDirectory $pwd -Verb RunAs
  2234.         Exit
  2235.     }
  2236. }
  2237.  
  2238. # Wait for key press
  2239. Function WaitForKey {
  2240.     Write-Host
  2241.     Write-Host "Tweaking complete!"
  2242.     Read-Host "Press ENTER to reboot and complete the optimization. You may also choose to manually reboot if you wish."
  2243. }
  2244.  
  2245. # Restart computer
  2246. Function Restart {
  2247.     Write-Host "Restarting..."
  2248.     Restart-Computer
  2249. }
  2250.  
  2251. # Test if registry path exists
  2252. function Test-RegistryValue {
  2253.     param (
  2254.  
  2255.      [parameter(Mandatory=$true)]
  2256.      [ValidateNotNullOrEmpty()]$Path,
  2257.  
  2258.     [parameter(Mandatory=$true)]
  2259.      [ValidateNotNullOrEmpty()]$Value
  2260.     )
  2261.  
  2262.     try {
  2263.  
  2264.     Get-ItemProperty -Path $Path | Select-Object -ExpandProperty $Value -ErrorAction Stop | Out-Null
  2265.      return $true
  2266.      }
  2267.  
  2268.     catch {
  2269.  
  2270.     return $false
  2271.  
  2272.     }
  2273. }
  2274.  
  2275.  
  2276. ##########
  2277. # Parse parameters and apply tweaks
  2278. ##########
  2279.  
  2280. Write-Host
  2281. Write-Host
  2282. Write-Host "WIN 10 Optimization Script For Windows 10 by BlackDragonBE"
  2283. Write-Host "(Adapted version of https://github.com/Disassembler0/Win10-Initial-Setup-Script by Disassembler <disassembler@dasm.cz>)"
  2284. Write-Host "--------------------------------------------"
  2285. Write-Host "Make sure you've checked which tweaks are turned on before running this. Edit by placing # before anything you don't want to run."
  2286. Write-Host
  2287. $confirmation = Read-Host "If you're sure you want to run this, press y and ENTER. If not, just press ENTER to cancel."
  2288.  
  2289. if ($confirmation -ne 'y') {
  2290.     Write-Host
  2291.     Write-Host "Cancelled script execution."
  2292.     exit
  2293. }
  2294.  
  2295. Write-Host
  2296. Write-Host "Let's roll!"
  2297.  
  2298.  
  2299. # Normalize path to preset file
  2300. $preset = ""
  2301. $PSCommandArgs = $args
  2302. If ($args -And $args[0].ToLower() -eq "-preset") {
  2303.     $preset = Resolve-Path $($args | Select-Object -Skip 1)
  2304.     $PSCommandArgs = "-preset `"$preset`""
  2305. }
  2306.  
  2307. # Load function names from command line arguments or a preset file
  2308. If ($args) {
  2309.     $tweaks = $args
  2310.     If ($preset) {
  2311.         $tweaks = Get-Content $preset -ErrorAction Stop | ForEach { $_.Trim() } | Where { $_ -ne "" -and $_[0] -ne "#" }
  2312.     }
  2313. }
  2314.  
  2315. # Call the desired tweak functions
  2316. $tweaks | ForEach { Invoke-Expression $_ }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement