Advertisement
BaSs_HaXoR

reclaimWindows10.ps1 (#1 .ps1 privacy script)

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