From ccc3682d162e8b7759a04e54b530beae5582a269 Mon Sep 17 00:00:00 2001 From: Michael Reber Date: Fri, 15 Nov 2019 11:52:11 +0100 Subject: [PATCH] Initial commit --- Default.cmd | 1 + Default.preset | 231 +++ LICENSE | 21 + README.md | 172 ++- Win10.ps1 | 60 + Win10.psm1 | 3650 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 4134 insertions(+), 1 deletion(-) create mode 100644 Default.cmd create mode 100644 Default.preset create mode 100644 LICENSE create mode 100644 Win10.ps1 create mode 100644 Win10.psm1 diff --git a/Default.cmd b/Default.cmd new file mode 100644 index 0000000..6f5200e --- /dev/null +++ b/Default.cmd @@ -0,0 +1 @@ +@powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%~dp0Win10.ps1" -include "%~dp0Win10.psm1" -preset "%~dpn0.preset" diff --git a/Default.preset b/Default.preset new file mode 100644 index 0000000..3372ba2 --- /dev/null +++ b/Default.preset @@ -0,0 +1,231 @@ +########## +# Win 10 / Server 2016 / Server 2019 Initial Setup Script - Default preset +# Author: Disassembler +# Version: v3.8, 2019-09-11 +# Modded by: Michael Reber +# Source: https://github.com/Disassembler0/Win10-Initial-Setup-Script +########## + +### Require administrator privileges ### +RequireAdmin + +### Privacy Tweaks ### +DisableTelemetry # EnableTelemetry +DisableWiFiSense # EnableWiFiSense +# DisableSmartScreen # EnableSmartScreen +# DisableWebSearch # EnableWebSearch +DisableAppSuggestions # EnableAppSuggestions +DisableActivityHistory # EnableActivityHistory +DisableBackgroundApps # EnableBackgroundApps +# DisableSensors # EnableSensors +DisableLocation # EnableLocation +DisableMapUpdates # EnableMapUpdates +DisableFeedback # EnableFeedback +DisableTailoredExperiences # EnableTailoredExperiences +DisableAdvertisingID # EnableAdvertisingID +DisableWebLangList # EnableWebLangList +DisableCortana # EnableCortana +# DisableBiometrics # EnableBiometrics +# DisableCamera # EnableCamera +# DisableMicrophone # EnableMicrophone +DisableErrorReporting # EnableErrorReporting +# SetP2PUpdateLocal # SetP2PUpdateInternet # SetP2PUpdateDisable +DisableDiagTrack # EnableDiagTrack +DisableWAPPush # EnableWAPPush +# EnableClearRecentFiles # DisableClearRecentFiles +# DisableRecentFiles # EnableRecentFiles + +### Security Tweaks ### +# SetUACLow # SetUACHigh +# EnableSharingMappedDrives # DisableSharingMappedDrives +DisableAdminShares # EnableAdminShares +# DisableFirewall # EnableFirewall +# HideDefenderTrayIcon # ShowDefenderTrayIcon +# DisableDefender # EnableDefender +# DisableDefenderCloud # EnableDefenderCloud +# EnableCtrldFolderAccess # DisableCtrldFolderAccess +# EnableCIMemoryIntegrity # DisableCIMemoryIntegrity +# EnableDefenderAppGuard # DisableDefenderAppGuard +HideAccountProtectionWarn # ShowAccountProtectionWarn +# DisableDownloadBlocking # EnableDownloadBlocking +# DisableScriptHost # EnableScriptHost +EnableDotNetStrongCrypto # DisableDotNetStrongCrypto +# EnableMeltdownCompatFlag # DisableMeltdownCompatFlag +EnableF8BootMenu # DisableF8BootMenu +# DisableBootRecovery # EnableBootRecovery +# DisableRecoveryAndReset # EnableRecoveryAndReset +SetDEPOptOut # SetDEPOptIn + +### Network Tweaks ### +SetCurrentNetworkPrivate # SetCurrentNetworkPublic +# SetUnknownNetworksPrivate # SetUnknownNetworksPublic +# DisableNetDevicesAutoInst # EnableNetDevicesAutoInst +# DisableHomeGroups # EnableHomeGroups +# DisableSMB1 # EnableSMB1 +# DisableSMBServer # EnableSMBServer +# DisableNetBIOS # EnableNetBIOS +# DisableLLMNR # EnableLLMNR +# DisableLLDP # EnableLLDP +# DisableLLTD # EnableLLTD +# DisableMSNetClient # EnableMSNetClient +# DisableQoS # EnableQoS +# DisableIPv4 # EnableIPv4 +# DisableIPv6 # EnableIPv6 +# DisableNCSIProbe # EnableNCSIProbe +# DisableConnectionSharing # EnableConnectionSharing +DisableRemoteAssistance # EnableRemoteAssistance +# EnableRemoteDesktop # DisableRemoteDesktop + +### Service Tweaks ### +# DisableUpdateMSRT # EnableUpdateMSRT +# DisableUpdateDriver # EnableUpdateDriver +EnableUpdateMSProducts # DisableUpdateMSProducts +# DisableUpdateAutoDownload # EnableUpdateAutoDownload +DisableUpdateRestart # EnableUpdateRestart +DisableMaintenanceWakeUp # EnableMaintenanceWakeUp +DisableSharedExperiences # EnableSharedExperiences +# EnableClipboardHistory # DisableClipboardHistory +DisableAutoplay # EnableAutoplay +DisableAutorun # EnableAutorun +# DisableRestorePoints # EnableRestorePoints +# EnableStorageSense # DisableStorageSense +# DisableDefragmentation # EnableDefragmentation +# DisableSuperfetch # EnableSuperfetch +# DisableIndexing # EnableIndexing +# DisableSwapFile # EnableSwapFile +# DisableRecycleBin # EnableRecycleBin +EnableNTFSLongPaths # DisableNTFSLongPaths +# DisableNTFSLastAccess # EnableNTFSLastAccess +# SetBIOSTimeUTC # SetBIOSTimeLocal +# EnableHibernation # DisableHibernation +# DisableSleepButton # EnableSleepButton +# DisableSleepTimeout # EnableSleepTimeout +# DisableFastStartup # EnableFastStartup +# DisableAutoRebootOnCrash # EnableAutoRebootOnCrash + +### UI Tweaks ### +DisableActionCenter # EnableActionCenter +DisableLockScreen # EnableLockScreen +# DisableLockScreenRS1 # EnableLockScreenRS1 +HideNetworkFromLockScreen # ShowNetworkOnLockScreen +HideShutdownFromLockScreen # ShowShutdownOnLockScreen +DisableLockScreenBlur # EnableLockScreenBlur +# DisableAeroShake # EnableAeroShake +DisableAccessibilityKeys # EnableAccessibilityKeys +ShowTaskManagerDetails # HideTaskManagerDetails +ShowFileOperationsDetails # HideFileOperationsDetails +# EnableFileDeleteConfirm # DisableFileDeleteConfirm +HideTaskbarSearch # ShowTaskbarSearchIcon # ShowTaskbarSearchBox +HideTaskView # ShowTaskView +ShowSmallTaskbarIcons # ShowLargeTaskbarIcons +# SetTaskbarCombineWhenFull # SetTaskbarCombineNever # SetTaskbarCombineAlways +HideTaskbarPeopleIcon # ShowTaskbarPeopleIcon +ShowTrayIcons # HideTrayIcons +# ShowSecondsInTaskbar # HideSecondsFromTaskbar +DisableSearchAppInStore # EnableSearchAppInStore +DisableNewAppPrompt # EnableNewAppPrompt +# HideRecentlyAddedApps # ShowRecentlyAddedApps +# HideMostUsedApps # ShowMostUsedApps +# SetControlPanelSmallIcons # SetControlPanelLargeIcons # SetControlPanelCategories +DisableShortcutInName # EnableShortcutInName +# HideShortcutArrow # ShowShortcutArrow +SetVisualFXPerformance # SetVisualFXAppearance +# EnableTitleBarColor # DisableTitleBarColor +# EnableDarkTheme # DisableDarkTheme +# AddENKeyboard # RemoveENKeyboard +# EnableNumlock # DisableNumlock +# DisableEnhPointerPrecision # EnableEnhPointerPrecision +# SetSoundSchemeNone # SetSoundSchemeDefault +# DisableStartupSound # EnableStartupSound +# DisableChangingSoundScheme # EnableChangingSoundScheme +# EnableVerboseStatus # DisableVerboseStatus +DisableF1HelpKey # EnableF1HelpKey + +### Explorer UI Tweaks ### +# ShowExplorerTitleFullPath # HideExplorerTitleFullPath +ShowKnownExtensions # HideKnownExtensions +ShowHiddenFiles # HideHiddenFiles +# ShowSuperHiddenFiles # HideSuperHiddenFiles +# ShowEmptyDrives # HideEmptyDrives +# ShowFolderMergeConflicts # HideFolderMergeConflicts +# EnableNavPaneExpand # DisableNavPaneExpand +# ShowNavPaneAllFolders # HideNavPaneAllFolders +# EnableFldrSeparateProcess # DisableFldrSeparateProcess +# EnableRestoreFldrWindows # DisableRestoreFldrWindows +# ShowEncCompFilesColor # HideEncCompFilesColor +# DisableSharingWizard # EnableSharingWizard +# HideSelectCheckboxes # ShowSelectCheckboxes +HideSyncNotifications # ShowSyncNotifications +HideRecentShortcuts # ShowRecentShortcuts +SetExplorerThisPC # SetExplorerQuickAccess +# HideQuickAccess # ShowQuickAccess +# HideRecycleBinFromDesktop # ShowRecycleBinOnDesktop +ShowThisPCOnDesktop # HideThisPCFromDesktop +# ShowUserFolderOnDesktop # HideUserFolderFromDesktop +# ShowControlPanelOnDesktop # HideControlPanelFromDesktop +# ShowNetworkOnDesktop # HideNetworkFromDesktop +# ShowBuildNumberOnDesktop # HideBuildNumberFromDesktop +HideDesktopFromThisPC # ShowDesktopInThisPC +# HideDesktopFromExplorer # ShowDesktopInExplorer +HideDocumentsFromThisPC # ShowDocumentsInThisPC +# HideDocumentsFromExplorer # ShowDocumentsInExplorer +HideDownloadsFromThisPC # ShowDownloadsInThisPC +# HideDownloadsFromExplorer # ShowDownloadsInExplorer +HideMusicFromThisPC # ShowMusicInThisPC +# HideMusicFromExplorer # ShowMusicInExplorer +HidePicturesFromThisPC # ShowPicturesInThisPC +# HidePicturesFromExplorer # ShowPicturesInExplorer +HideVideosFromThisPC # ShowVideosInThisPC +# HideVideosFromExplorer # ShowVideosInExplorer +Hide3DObjectsFromThisPC # Show3DObjectsInThisPC +# Hide3DObjectsFromExplorer # Show3DObjectsInExplorer +# HideIncludeInLibraryMenu # ShowIncludeInLibraryMenu +# HideGiveAccessToMenu # ShowGiveAccessToMenu +# HideShareMenu # ShowShareMenu +# DisableThumbnails # EnableThumbnails +DisableThumbnailCache # EnableThumbnailCache +DisableThumbsDBOnNetwork # EnableThumbsDBOnNetwork + +### Application Tweaks ### +DisableOneDrive # EnableOneDrive +UninstallOneDrive # InstallOneDrive +UninstallMsftBloat # InstallMsftBloat +UninstallThirdPartyBloat # InstallThirdPartyBloat +# UninstallWindowsStore # InstallWindowsStore +DisableXboxFeatures # EnableXboxFeatures +# DisableFullscreenOptims # EnableFullscreenOptims +DisableAdobeFlash # EnableAdobeFlash +DisableEdgePreload # EnableEdgePreload +DisableEdgeShortcutCreation # EnableEdgeShortcutCreation +DisableIEFirstRun # EnableIEFirstRun +DisableFirstLogonAnimation # EnableFirstLogonAnimation +DisableMediaSharing # EnableMediaSharing +# UninstallMediaPlayer # InstallMediaPlayer +# UninstallInternetExplorer # InstallInternetExplorer +# UninstallWorkFolders # InstallWorkFolders +# UninstallPowerShellV2 # InstallPowerShellV2 +# InstallLinuxSubsystem # UninstallLinuxSubsystem +# InstallHyperV # UninstallHyperV +# InstallNET23 # UninstallNET23 +SetPhotoViewerAssociation # UnsetPhotoViewerAssociation +AddPhotoViewerOpenWith # RemovePhotoViewerOpenWith +# UninstallPDFPrinter # InstallPDFPrinter +UninstallXPSPrinter # InstallXPSPrinter +RemoveFaxPrinter # AddFaxPrinter +# UninstallFaxAndScan # InstallFaxAndScan + +### Server Specific Tweaks ### +# HideServerManagerOnLogin # ShowServerManagerOnLogin +# DisableShutdownTracker # EnableShutdownTracker +# DisablePasswordPolicy # EnablePasswordPolicy +# DisableCtrlAltDelLogin # EnableCtrlAltDelLogin +# DisableIEEnhancedSecurity # EnableIEEnhancedSecurity +# EnableAudio # DisableAudio + +### Unpinning ### +# UnpinStartMenuTiles +# UnpinTaskbarIcons + +### Auxiliary Functions ### +WaitForKey +Restart diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..ff7ffe1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2019 Disassembler + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index e1537a5..7c0201c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,173 @@ # win10-initial-setup-script -PowerShell hardening and setup script for initial configuration of Windows 10 / Server 2016 or Server 2019 \ No newline at end of file +PowerShell hardening and setup script for initial configuration of Windows 10 / Server 2016 or Server 2019 + +## Usage +If you just want to run the script with the default preset, download and unpack the master-branch and simply double-click on the *Default.cmd* file and confirm *User Account Control* prompt. Make sure your account is a member of *Administrators* group as the script attempts to run with elevated privileges. + +The script supports command line options and parameters which can help you customize the tweak selection or even add your own custom tweaks, however these features require some basic knowledge of command line usage and PowerShell scripting. Refer to [Advanced usage](#advanced-usage) section for more details. + +  + +## Windows builds overview + +| Version | Code name | Marketing name | Build | +| :-----: | ----------------------- | ---------------------- | :---: | +| 1507 | Threshold 1 (TH1 / RTM) | N/A | 10240 | +| 1511 | Threshold 2 (TH2) | November Update | 10586 | +| 1607 | Redstone 1 (RS1) | Anniversary Update | 14393 | +| 1703 | Redstone 2 (RS2) | Creators Update | 15063 | +| 1709 | Redstone 3 (RS3) | Fall Creators Update | 16299 | +| 1803 | Redstone 4 (RS4) | April 2018 Update | 17134 | +| 1809 | Redstone 5 (RS5) | October 2018 Update | 17763 | +| 1903 | 19H1 | May 2019 Update | 18362 | + +  + +## Advanced usage + + powershell.exe -NoProfile -ExecutionPolicy Bypass -File Win10.ps1 [-include filename] [-preset filename] [-log logname] [[!]tweakname] + + -include filename load module with user-defined tweaks + -preset filename load preset with tweak names to apply + -log logname save script output to a file + tweakname apply tweak with this particular name + !tweakname remove tweak with this particular name from selection + +### Presets + +The tweak library consists of separate idempotent functions, containing one tweak each. The functions can be grouped to *presets*. Preset is simply a list of function names which should be called. Any function which is not present or is commented in a preset will not be called, thus the corresponding tweak will not be applied. In order for the script to do something, you need to supply at least one tweak library via `-include` and at least one tweak name, either via `-preset` or directly as command line argument. + +The tweak names can be prefixed with exclamation mark (`!`) which will instead cause the tweak to be removed from selection. This is useful in cases when you want to apply the whole preset, but omit a few specific tweaks in the current run. Alternatively, you can have a preset which "patches" another preset by adding and removing a small amount of tweaks. + +To supply a customized preset, you can either pass the function names directly as arguments. + + powershell.exe -NoProfile -ExecutionPolicy Bypass -File Win10.ps1 -include Win10.psm1 EnableFirewall EnableDefender + +Or you can create a file where you write the function names (one function name per line, no commas or quotes, whitespaces allowed, comments starting with `#`) and then pass the filename using `-preset` parameter. +Example of a preset file `mypreset.txt`: + + # Security tweaks + EnableFirewall + EnableDefender + + # UI tweaks + ShowKnownExtensions + ShowHiddenFiles # Only hidden, not system + +Command using the preset file above: + + powershell.exe -NoProfile -ExecutionPolicy Bypass -File Win10.ps1 -include Win10.psm1 -preset mypreset.txt + +### Includes + +The script also supports inclusion of custom tweaks from user-supplied modules passed via `-include` parameter. The content of the user-supplied module is completely up to the user, however it is strongly recommended to have the tweaks separated in respective functions as the main tweak library has. The user-supplied scripts are loaded into the main script via `Import-Module`, so the library should ideally be a `.psm1` PowerShell module. +Example of a user-supplied tweak library `mytweaks.psm1`: + +```powershell +Function MyTweak1 { + Write-Output "Running MyTweak1..." + # Do something +} + +Function MyTweak2 { + Write-Output "Running MyTweak2..." + # Do something else +} +``` + +Command using the script above: + + powershell.exe -NoProfile -ExecutionPolicy Bypass -File Win10.ps1 -include mytweaks.psm1 MyTweak1 MyTweak2 + +### Combination + +All features described above can be combined. You can have a preset which includes both tweaks from the original script and your personal ones. Both `-include` and `-preset` options can be used more than once, so you can split your tweaks into groups and then combine them based on your current needs. The `-include` modules are always imported before the first tweak is applied, so the order of the command line parameters doesn't matter and neither does the order of the tweaks (except for `RequireAdmin`, which should always be called first and `Restart`, which should be always called last). It can happen that some tweaks are applied more than once during a singe run because you have them in multiple presets. That shouldn't cause any problems as the tweaks are idempotent. +Example of a preset file `otherpreset.txt`: + + MyTweak1 + MyTweak2 + !ShowHiddenFiles # Will remove the tweak from selection + WaitForKey + +Command using all three examples combined: + + powershell.exe -NoProfile -ExecutionPolicy Bypass -File Win10.ps1 -include Win10.psm1 -include mytweaks.psm1 -preset mypreset.txt -preset otherpreset.txt Restart + +  + +### Logging + +If you'd like to store output from the script execution, you can do so using `-log` parameter followed by a filename of the log file you want to create. For example: + + powershell.exe -NoProfile -ExecutionPolicy Bypass -File Win10.ps1 -include Win10.psm1 -preset mypreset.txt -log myoutput.log + +The logging is done using PowerShell `Start-Transcript` cmdlet, which writes extra information about current environment (date, machine and user name, command used for execution etc.) to the beginning of the file and logs both standard output and standard error streams. + +  + +## Contribution guidelines + +Following is a list of rules which I'm trying to apply in this project. The rules are not binding and I accept pull requests even if they don't adhere to them, as long as their purpose and content are clear. In cases when there are too many rule violations, I might simply redo the whole functionality and reject the PR while still crediting you. If you'd like to make my work easier, please consider adhering to the following rules too. + +### Function naming +Try to give a function a meaningful name up to 25 characters long, which gives away the purpose of the function. Use verbs like `Enable`/`Disable`, `Show`/`Hide`, `Install`/`Uninstall`, `Add`/`Remove` in the beginning of the function name. In case the function doesn't fit any of these verbs, come up with another name, beginning with the verb `Set`, which indicates what the function does, e.g. `SetCurrentNetworkPrivate` and `SetCurrentNetworkPublic`. + +### Revert functions +Always add a function with opposite name (or equivalent) which reverts the behavior to default. The default is considered freshly installed Windows 10 or Windows Server 2016 / 2019 with no adjustments made during or after the installation. If you don't have access to either of these, create the revert function to the best of your knowledge and I will fill in the rest if necessary. + +### Function similarities +Check if there isn't already a function with similar purpose as the one you're trying to add. As long as the name and objective of the existing function is unchanged, feel free to add your tweak to that function rather than creating a new one. + +### Function grouping +Try to group functions thematically. There are already several major groups (privacy, security, services etc.), but even within these, some tweaks may be related to each other. In such case, add a new tweak below the existing one and not to the end of the whole group. + +### Default preset +Always add a reference to the tweak and its revert function in the *Default.preset*. Add references to both functions on the same line (mind the spaces) and always comment out the revert function. Whether to comment out also the tweak in the default preset is a matter of personal preference. The rule of thumb is that if the tweak makes the system faster, smoother, more secure and less obtrusive, it should be enabled by default. Usability has preference over performance (that's why e.g. indexing is kept enabled). + +### Repeatability +Unless applied on unsupported system, all functions have to be applicable repeatedly without any errors. When you're creating a registry key, always check first if the key doesn't happen to already exist. When you're deleting registry value, always append `-ErrorAction SilentlyContinue` to prevent errors while deleting already deleted values. + +### Input / output hiding +Suppress all output generated by commands and cmdlets using `| Out-Null` or `-ErrorAction SilentlyContinue` where applicable. Whenever an input is needed, use appropriate arguments to suppress the prompt and programmatically provide values for the command to run (e.g. using `-Confirm:$false`). The only acceptable output is from the `Write-Output` cmdlets in the beginning of each function and from non-suppressible cmdlets like `Remove-AppxPackage`. + +### Registry +Create the registry keys only if they don't exist on fresh installation if Windows 10 or Windows Server 2016 / 2019. When deleting registry, delete only registry values, not the whole keys. When you're setting registry values, always use `Set-ItemProperty` instead of `New-ItemProperty`. When you're removing registry values, choose either `Set-ItemProperty` or `Remove-ItemProperty` to reinstate the same situation as it was on the clean installation. Again, if you don't know what the original state was, let me know in PR description and I will fill in the gaps. When you need to use `HKEY_USERS` registry hive, always add following snippet before the registry modification to ensure portability. + +```powershell +If (!(Test-Path "HKU:")) { + New-PSDrive -Name HKU -PSProvider Registry -Root HKEY_USERS | Out-Null +} +``` + +### Force usage +Star Wars jokes aside, don't use `-Force` option unless absolutely necessary. The only permitted case is when you're creating a new registry key (not a value) and you need to ensure that all parent keys will be created as well. In such case always check first if the key doesn't already exist, otherwise you will delete all its existing values. + +### Comments +Always add a simple comment above the function briefly describing what the function does, especially if it has an ambiguous name or if there is some logic hidden under the hood. If you know that the tweak doesn't work on some editions of Windows 10 or on Windows Server, state it in the comment too. Add a `Write-Output` cmdlet with the short description of action also to the first line of the function body, so the user can see what is being executed and which function is the problematic one whenever an error occurs. The comment is written in present simple tense, the `Write-Output` in present continuous with ellipsis (resp. three dots) at the end. + +### Coding style +Indent using tabs, enclose all string values in double quotes (`"`) and strictly use `PascalCase` wherever possible. Put opening curly bracket on the same line as the function name or condition, but leave the closing bracket on a separate line for readability. + +### Examples + +**Naming example**: Consider function `EnableFastMenu`. What does it do? Which menu? How fast is *fast*? A better name might be `EnableFastMenuFlyout`, so it's a bit clearer that we're talking about the menu flyouts delays. But the counterpart function would be `DisableFastMenuFlyouts` which is not entirely true. We're not *disabling* anything, we're just making it slow again. So even better might be to name them `SetFastMenuFlyouts` and `SetSlowMenuFlyouts`. Or better yet, just add the functionality to already existing `SetVisualFXPerformance`/`SetVisualFXAppearance`. Even though the names are not 100% match, they aim to tweak similar aspects and operate within the same registry keys. + +**Coding example:** The following code applies most of the rules mentioned above (naming, output hiding, repeatability, force usage, comments and coding style). + +```powershell +# Enable some feature +Function EnableSomeFeature { + Write-Output "Enabling some feature..." + If (!(Test-Path "HKLM:\Some\Registry\Key")) { + New-Item -Path "HKLM:\Some\Registry\Key" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\Some\Registry\Key" -Name "SomeValueName" -Type String -Value "SomeValue" +} + +# Disable some feature +Function DisableSomeFeature { + Write-Output "Disabling some feature..." + Remove-ItemProperty -Path "HKLM:\Some\Registry\Key" -Name "SomeValueName" -ErrorAction SilentlyContinue +} +``` diff --git a/Win10.ps1 b/Win10.ps1 new file mode 100644 index 0000000..a0f6ad4 --- /dev/null +++ b/Win10.ps1 @@ -0,0 +1,60 @@ +########## +# Win 10 /Server 2016 / Server 2019 Initial Setup Script - Main execution loop +# Author: Disassembler +# Version: v3.8, 2019-09-11 +# Modded by: Michael Reber +# Source: https://github.com/Disassembler0/Win10-Initial-Setup-Script +########## + +# Relaunch the script with administrator privileges +Function RequireAdmin { + If (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]"Administrator")) { + Start-Process powershell.exe "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`" $PSCommandArgs" -Verb RunAs + Exit + } +} + +$tweaks = @() +$PSCommandArgs = @() + +Function AddOrRemoveTweak($tweak) { + If ($tweak[0] -eq "!") { + # If the name starts with exclamation mark (!), exclude the tweak from selection + $script:tweaks = $script:tweaks | Where-Object { $_ -ne $tweak.Substring(1) } + } ElseIf ($tweak -ne "") { + # Otherwise add the tweak + $script:tweaks += $tweak + } +} + +# Parse and resolve paths in passed arguments +$i = 0 +While ($i -lt $args.Length) { + If ($args[$i].ToLower() -eq "-include") { + # Resolve full path to the included file + $include = Resolve-Path $args[++$i] -ErrorAction Stop + $PSCommandArgs += "-include `"$include`"" + # Import the included file as a module + Import-Module -Name $include -ErrorAction Stop + } ElseIf ($args[$i].ToLower() -eq "-preset") { + # Resolve full path to the preset file + $preset = Resolve-Path $args[++$i] -ErrorAction Stop + $PSCommandArgs += "-preset `"$preset`"" + # Load tweak names from the preset file + Get-Content $preset -ErrorAction Stop | ForEach-Object { AddOrRemoveTweak($_.Split("#")[0].Trim()) } + } ElseIf ($args[$i].ToLower() -eq "-log") { + # Resolve full path to the output file + $log = $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($args[++$i]) + $PSCommandArgs += "-log `"$log`"" + # Record session to the output file + Start-Transcript $log + } Else { + $PSCommandArgs += $args[$i] + # Load tweak names from command line + AddOrRemoveTweak($args[$i]) + } + $i++ +} + +# Call the desired tweak functions +$tweaks | ForEach-Object { Invoke-Expression $_ } diff --git a/Win10.psm1 b/Win10.psm1 new file mode 100644 index 0000000..fe77703 --- /dev/null +++ b/Win10.psm1 @@ -0,0 +1,3650 @@ +########## +# Win 10 / Server 2016 / Server 2019 Initial Setup Script - Tweak library +# Author: Disassembler +# Version: v3.8, 2019-09-11 +# Modded by: Michael Reber +# Source: https://github.com/Disassembler0/Win10-Initial-Setup-Script +########## + +########## +#region Privacy Tweaks +########## + +# Disable Telemetry +# Note: This tweak also disables the possibility to join Windows Insider Program, as it requires Telemetry data. +# Windows Update control panel may show message "Your device is at risk because it's out of date and missing important security and quality updates. Let's get you back on track so Windows can run more securely. Select this button to get going". +# In such case, enable telemetry, run Windows update and then disable telemetry again. +# See also https://github.com/Disassembler0/Win10-Initial-Setup-Script/issues/57 and https://github.com/Disassembler0/Win10-Initial-Setup-Script/issues/92 +Function DisableTelemetry { + Write-Output "Disabling Telemetry..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PreviewBuilds")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PreviewBuilds" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PreviewBuilds" -Name "AllowBuildPreview" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Software Protection Platform")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Software Protection Platform" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Software Protection Platform" -Name "NoGenTicket" -Type DWord -Value 1 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\SQMClient\Windows")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\SQMClient\Windows" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\SQMClient\Windows" -Name "CEIPEnable" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat" -Name "AITEnable" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat" -Name "DisableInventory" -Type DWord -Value 1 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\AppV\CEIP")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\AppV\CEIP" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\AppV\CEIP" -Name "CEIPEnable" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\TabletPC")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\TabletPC" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\TabletPC" -Name "PreventHandwritingDataSharing" -Type DWord -Value 1 + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\TextInput")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\TextInput" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\TextInput" -Name "AllowLinguisticDataCollection" -Type DWord -Value 0 + Disable-ScheduledTask -TaskName "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" | Out-Null + Disable-ScheduledTask -TaskName "Microsoft\Windows\Application Experience\ProgramDataUpdater" | Out-Null + Disable-ScheduledTask -TaskName "Microsoft\Windows\Autochk\Proxy" | Out-Null + Disable-ScheduledTask -TaskName "Microsoft\Windows\Customer Experience Improvement Program\Consolidator" | Out-Null + Disable-ScheduledTask -TaskName "Microsoft\Windows\Customer Experience Improvement Program\UsbCeip" | Out-Null + Disable-ScheduledTask -TaskName "Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector" | Out-Null +} + +# Enable Telemetry +Function EnableTelemetry { + Write-Output "Enabling Telemetry..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 3 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 3 + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "AllowTelemetry" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PreviewBuilds" -Name "AllowBuildPreview" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Software Protection Platform" -Name "NoGenTicket" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\SQMClient\Windows" -Name "CEIPEnable" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat" -Name "AITEnable" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat" -Name "DisableInventory" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\AppV\CEIP" -Name "CEIPEnable" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\TabletPC" -Name "PreventHandwritingDataSharing" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\TextInput" -Name "AllowLinguisticDataCollection" -ErrorAction SilentlyContinue + Enable-ScheduledTask -TaskName "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" | Out-Null + Enable-ScheduledTask -TaskName "Microsoft\Windows\Application Experience\ProgramDataUpdater" | Out-Null + Enable-ScheduledTask -TaskName "Microsoft\Windows\Autochk\Proxy" | Out-Null + Enable-ScheduledTask -TaskName "Microsoft\Windows\Customer Experience Improvement Program\Consolidator" | Out-Null + Enable-ScheduledTask -TaskName "Microsoft\Windows\Customer Experience Improvement Program\UsbCeip" | Out-Null + Enable-ScheduledTask -TaskName "Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector" | Out-Null +} + +# Disable Wi-Fi Sense +Function DisableWiFiSense { + Write-Output "Disabling Wi-Fi Sense..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" -Name "Value" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots" -Name "Value" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" -Name "AutoConnectAllowedOEM" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" -Name "WiFISenseAllowed" -Type DWord -Value 0 +} + +# Enable Wi-Fi Sense +Function EnableWiFiSense { + Write-Output "Enabling Wi-Fi Sense..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" -Name "Value" -Type DWord -Value 1 + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots" -Name "Value" -Type DWord -Value 1 + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" -Name "AutoConnectAllowedOEM" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" -Name "WiFISenseAllowed" -ErrorAction SilentlyContinue +} + +# Disable SmartScreen Filter +Function DisableSmartScreen { + Write-Output "Disabling SmartScreen Filter..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "EnableSmartScreen" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\PhishingFilter")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\PhishingFilter" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\PhishingFilter" -Name "EnabledV9" -Type DWord -Value 0 +} + +# Enable SmartScreen Filter +Function EnableSmartScreen { + Write-Output "Enabling SmartScreen Filter..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "EnableSmartScreen" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\PhishingFilter" -Name "EnabledV9" -ErrorAction SilentlyContinue +} + +# Disable Web Search in Start Menu +Function DisableWebSearch { + Write-Output "Disabling Bing Search in Start Menu..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "BingSearchEnabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "CortanaConsent" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "DisableWebSearch" -Type DWord -Value 1 +} + +# Enable Web Search in Start Menu +Function EnableWebSearch { + Write-Output "Enabling Bing Search in Start Menu..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "BingSearchEnabled" -ErrorAction SilentlyContinue + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "CortanaConsent" -Type DWord -Value 1 + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "DisableWebSearch" -ErrorAction SilentlyContinue +} + +# Disable Application suggestions and automatic installation +Function DisableAppSuggestions { + Write-Output "Disabling Application suggestions..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "ContentDeliveryAllowed" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "OemPreInstalledAppsEnabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "PreInstalledAppsEnabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "PreInstalledAppsEverEnabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SilentInstalledAppsEnabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-310093Enabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-314559Enabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338387Enabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338388Enabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338389Enabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338393Enabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-353694Enabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-353696Enabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-353698Enabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SystemPaneSuggestionsEnabled" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableWindowsConsumerFeatures" -Type DWord -Value 1 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsInkWorkspace")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsInkWorkspace" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsInkWorkspace" -Name "AllowSuggestedAppsInWindowsInkWorkspace" -Type DWord -Value 0 + # Empty placeholder tile collection in registry cache and restart Start Menu process to reload the cache + If ([System.Environment]::OSVersion.Version.Build -ge 17134) { + $key = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount\*windows.data.placeholdertilecollection\Current" + Set-ItemProperty -Path $key.PSPath -Name "Data" -Type Binary -Value $key.Data[0..15] + Stop-Process -Name "ShellExperienceHost" -Force -ErrorAction SilentlyContinue + } +} + +# Enable Application suggestions and automatic installation +Function EnableAppSuggestions { + Write-Output "Enabling Application suggestions..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "ContentDeliveryAllowed" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "OemPreInstalledAppsEnabled" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "PreInstalledAppsEnabled" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "PreInstalledAppsEverEnabled" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SilentInstalledAppsEnabled" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338388Enabled" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338389Enabled" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-353694Enabled" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-353696Enabled" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SystemPaneSuggestionsEnabled" -Type DWord -Value 1 + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-310093Enabled" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-314559Enabled" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338387Enabled" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-338393Enabled" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name "SubscribedContent-353698Enabled" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableWindowsConsumerFeatures" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsInkWorkspace" -Name "AllowSuggestedAppsInWindowsInkWorkspace" -ErrorAction SilentlyContinue +} + +# Disable Activity History feed in Task View - Note: The checkbox "Let Windows collect my activities from this PC" remains checked even when the function is disabled +Function DisableActivityHistory { + Write-Output "Disabling Activity History..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "EnableActivityFeed" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "PublishUserActivities" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "UploadUserActivities" -Type DWord -Value 0 +} + +# Enable Activity History feed in Task View +Function EnableActivityHistory { + Write-Output "Enabling Activity History..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "EnableActivityFeed" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "PublishUserActivities" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "UploadUserActivities" -ErrorAction SilentlyContinue +} + +# 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, ShellExperience host breaks toasts and notifications +Function DisableBackgroundApps { + Write-Output "Disabling Background application access..." + Get-ChildItem -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications" -Exclude "Microsoft.Windows.Cortana*","Microsoft.Windows.ShellExperienceHost*" | ForEach-Object { + Set-ItemProperty -Path $_.PsPath -Name "Disabled" -Type DWord -Value 1 + Set-ItemProperty -Path $_.PsPath -Name "DisabledByUser" -Type DWord -Value 1 + } +} + +# Enable Background application access +Function EnableBackgroundApps { + Write-Output "Enabling Background application access..." + Get-ChildItem -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications" | ForEach-Object { + Remove-ItemProperty -Path $_.PsPath -Name "Disabled" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path $_.PsPath -Name "DisabledByUser" -ErrorAction SilentlyContinue + } +} + +# Disable sensor features, such as screen auto rotation +Function DisableSensors { + Write-Output "Disabling sensors..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" -Name "DisableSensors" -Type DWord -Value 1 +} + +# Enable sensor features +Function EnableSensors { + Write-Output "Enabling sensors..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" -Name "DisableSensors" -ErrorAction SilentlyContinue +} + +# Disable location feature and scripting for the location feature +Function DisableLocation { + Write-Output "Disabling location services..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" -Name "DisableLocation" -Type DWord -Value 1 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" -Name "DisableLocationScripting" -Type DWord -Value 1 +} + +# Enable location feature and scripting for the location feature +Function EnableLocation { + Write-Output "Enabling location services..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" -Name "DisableLocation" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\LocationAndSensors" -Name "DisableLocationScripting" -ErrorAction SilentlyContinue +} + +# Disable automatic Maps updates +Function DisableMapUpdates { + Write-Output "Disabling automatic Maps updates..." + Set-ItemProperty -Path "HKLM:\SYSTEM\Maps" -Name "AutoUpdateEnabled" -Type DWord -Value 0 +} + +# Enable automatic Maps updates +Function EnableMapUpdates { + Write-Output "Enable automatic Maps updates..." + Remove-ItemProperty -Path "HKLM:\SYSTEM\Maps" -Name "AutoUpdateEnabled" -ErrorAction SilentlyContinue +} + +# Disable Feedback +Function DisableFeedback { + Write-Output "Disabling Feedback..." + If (!(Test-Path "HKCU:\Software\Microsoft\Siuf\Rules")) { + New-Item -Path "HKCU:\Software\Microsoft\Siuf\Rules" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Siuf\Rules" -Name "NumberOfSIUFInPeriod" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "DoNotShowFeedbackNotifications" -Type DWord -Value 1 + Disable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClient" -ErrorAction SilentlyContinue | Out-Null + Disable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClientOnScenarioDownload" -ErrorAction SilentlyContinue | Out-Null +} + +# Enable Feedback +Function EnableFeedback { + Write-Output "Enabling Feedback..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Siuf\Rules" -Name "NumberOfSIUFInPeriod" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "DoNotShowFeedbackNotifications" -ErrorAction SilentlyContinue + Enable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClient" -ErrorAction SilentlyContinue | Out-Null + Enable-ScheduledTask -TaskName "Microsoft\Windows\Feedback\Siuf\DmClientOnScenarioDownload" -ErrorAction SilentlyContinue | Out-Null +} + +# Disable Tailored Experiences +Function DisableTailoredExperiences { + Write-Output "Disabling Tailored Experiences..." + If (!(Test-Path "HKCU:\Software\Policies\Microsoft\Windows\CloudContent")) { + New-Item -Path "HKCU:\Software\Policies\Microsoft\Windows\CloudContent" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\CloudContent" -Name "DisableTailoredExperiencesWithDiagnosticData" -Type DWord -Value 1 +} + +# Enable Tailored Experiences +Function EnableTailoredExperiences { + Write-Output "Enabling Tailored Experiences..." + Remove-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\CloudContent" -Name "DisableTailoredExperiencesWithDiagnosticData" -ErrorAction SilentlyContinue +} + +# Disable Advertising ID +Function DisableAdvertisingID { + Write-Output "Disabling Advertising ID..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo" -Name "DisabledByGroupPolicy" -Type DWord -Value 1 +} + +# Enable Advertising ID +Function EnableAdvertisingID { + Write-Output "Enabling Advertising ID..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo" -Name "DisabledByGroupPolicy" -ErrorAction SilentlyContinue +} + +# Disable setting 'Let websites provide locally relevant content by accessing my language list' +Function DisableWebLangList { + Write-Output "Disabling Website Access to Language List..." + Set-ItemProperty -Path "HKCU:\Control Panel\International\User Profile" -Name "HttpAcceptLanguageOptOut" -Type DWord -Value 1 +} + +# Enable setting 'Let websites provide locally relevant content by accessing my language list' +Function EnableWebLangList { + Write-Output "Enabling Website Access to Language List..." + Remove-ItemProperty -Path "HKCU:\Control Panel\International\User Profile" -Name "HttpAcceptLanguageOptOut" -ErrorAction SilentlyContinue +} + +# Disable Cortana +Function DisableCortana { + Write-Output "Disabling Cortana..." + If (!(Test-Path "HKCU:\Software\Microsoft\Personalization\Settings")) { + New-Item -Path "HKCU:\Software\Microsoft\Personalization\Settings" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Personalization\Settings" -Name "AcceptedPrivacyPolicy" -Type DWord -Value 0 + If (!(Test-Path "HKCU:\Software\Microsoft\InputPersonalization\TrainedDataStore")) { + New-Item -Path "HKCU:\Software\Microsoft\InputPersonalization\TrainedDataStore" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\InputPersonalization" -Name "RestrictImplicitTextCollection" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\InputPersonalization" -Name "RestrictImplicitInkCollection" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\InputPersonalization\TrainedDataStore" -Name "HarvestContacts" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\Experience\AllowCortana" -Name "Value" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "AllowCortana" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\InputPersonalization")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\InputPersonalization" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\InputPersonalization" -Name "AllowInputPersonalization" -Type DWord -Value 0 +} + +# Enable Cortana +Function EnableCortana { + Write-Output "Enabling Cortana..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Personalization\Settings" -Name "AcceptedPrivacyPolicy" -ErrorAction SilentlyContinue + Set-ItemProperty -Path "HKCU:\Software\Microsoft\InputPersonalization" -Name "RestrictImplicitTextCollection" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\InputPersonalization" -Name "RestrictImplicitInkCollection" -Type DWord -Value 0 + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\InputPersonalization\TrainedDataStore" -Name "HarvestContacts" -ErrorAction SilentlyContinue + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\Experience\AllowCortana" -Name "Value" -Type DWord -Value 1 + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "AllowCortana" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\InputPersonalization" -Name "AllowInputPersonalization" -ErrorAction SilentlyContinue +} + +# Disable biometric features in Windows. Note - it's recommended to create a password recovery disk, if you log on using biometrics. +Function DisableBiometrics { + Write-Output "Disabling biometric services..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Biometrics")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Biometrics" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Biometrics" -Name "Enabled" -Type DWord -Value 0 +} + +# Enable biometric features +Function EnableBiometrics { + Write-Output "Enabling biometric services..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Biometrics" -Name "Enabled" -ErrorAction SilentlyContinue +} + +# Disable access to camera from ModernUI applications +Function DisableCamera { + Write-Output "Disabling access to camera from ModernUI applications..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Camera")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Camera" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Camera" -Name "AllowCamera" -Type DWord -Value 0 +} + +# Enable access to camera in ModernUI applications +Function EnableCamera { + Write-Output "Enabling access to camera from ModernUI applications..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Camera" -Name "AllowCamera" -ErrorAction SilentlyContinue +} + +# Disable access to microphone in ModernUI applications +Function DisableMicrophone { + Write-Output "Disabling access to microphone in ModernUI applications..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name "LetAppsAccessMicrophone" -Type DWord -Value 2 +} + +# Enable access to microphone in ModernUI applications +Function EnableMicrophone { + Write-Output "Enabling access to microphone from ModernUI applications..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name "LetAppsAccessMicrophone" -ErrorAction SilentlyContinue +} + +# Disable Error reporting +Function DisableErrorReporting { + Write-Output "Disabling Error reporting..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name "Disabled" -Type DWord -Value 1 + Disable-ScheduledTask -TaskName "Microsoft\Windows\Windows Error Reporting\QueueReporting" | Out-Null +} + +# Enable Error reporting +Function EnableErrorReporting { + Write-Output "Enabling Error reporting..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name "Disabled" -ErrorAction SilentlyContinue + Enable-ScheduledTask -TaskName "Microsoft\Windows\Windows Error Reporting\QueueReporting" | Out-Null +} + +# Restrict Windows Update P2P delivery optimization to computers in local network - Default since 1703 +Function SetP2PUpdateLocal { + Write-Output "Restricting Windows Update P2P optimization to local network..." + If ([System.Environment]::OSVersion.Version.Build -eq 10240) { + # Method used in 1507 + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -Type DWord -Value 1 + } ElseIf ([System.Environment]::OSVersion.Version.Build -le 14393) { + # Method used in 1511 and 1607 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" -Name "DODownloadMode" -Type DWord -Value 1 + } Else { + # Method used since 1703 + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" -Name "DODownloadMode" -ErrorAction SilentlyContinue + } +} + +# Unrestrict Windows Update P2P delivery optimization to both local networks and internet - Default in 1507 - 1607 +Function SetP2PUpdateInternet { + Write-Output "Unrestricting Windows Update P2P optimization to internet..." + If ([System.Environment]::OSVersion.Version.Build -eq 10240) { + # Method used in 1507 + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -Type DWord -Value 3 + } ElseIf ([System.Environment]::OSVersion.Version.Build -eq 14393) { + # Method used in 1511 and 1607 + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" -Name "DODownloadMode" -ErrorAction SilentlyContinue + } Else { + # Method used since 1703 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" -Name "DODownloadMode" -Type DWord -Value 3 + } +} + +# Disable Windows Update P2P delivery optimization completely +Function SetP2PUpdateDisable { + Write-Output "Disabling Windows Update P2P optimization..." + If ([System.Environment]::OSVersion.Version.Build -eq 10240) { + # Method used in 1507 + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -Type DWord -Value 0 + } Else { + # Method used since 1511 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" -Name "DODownloadMode" -Type DWord -Value 100 + } +} + +# Stop and disable Connected User Experiences and Telemetry (previously named Diagnostics Tracking Service) +Function DisableDiagTrack { + Write-Output "Stopping and disabling Connected User Experiences and Telemetry Service..." + Stop-Service "DiagTrack" -WarningAction SilentlyContinue + Set-Service "DiagTrack" -StartupType Disabled +} + +# Enable and start Connected User Experiences and Telemetry (previously named Diagnostics Tracking Service) +Function EnableDiagTrack { + Write-Output "Enabling and starting Connected User Experiences and Telemetry Service ..." + Set-Service "DiagTrack" -StartupType Automatic + Start-Service "DiagTrack" -WarningAction SilentlyContinue +} + +# Stop and disable Device Management Wireless Application Protocol (WAP) Push Service +Function DisableWAPPush { + Write-Output "Stopping and disabling Device Management WAP Push Service..." + Stop-Service "dmwappushservice" -WarningAction SilentlyContinue + Set-Service "dmwappushservice" -StartupType Disabled +} + +# Enable and start Device Management Wireless Application Protocol (WAP) Push Service +Function EnableWAPPush { + Write-Output "Enabling and starting Device Management WAP Push Service..." + Set-Service "dmwappushservice" -StartupType Automatic + Start-Service "dmwappushservice" -WarningAction SilentlyContinue + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\dmwappushservice" -Name "DelayedAutoStart" -Type DWord -Value 1 +} + +# Enable clearing of recent files on exit +# Empties most recently used (MRU) items lists such as 'Recent Items' menu on the Start menu, jump lists, and shortcuts at the bottom of the 'File' menu in applications during every logout. +Function EnableClearRecentFiles { + Write-Output "Enabling clearing of recent files on exit..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "ClearRecentDocsOnExit" -Type DWord -Value 1 +} + +# Disable clearing of recent files on exit +Function DisableClearRecentFiles { + Write-Output "Disabling clearing of recent files on exit..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "ClearRecentDocsOnExit" -ErrorAction SilentlyContinue +} + +# Disable recent files lists +# Stops creating most recently used (MRU) items lists such as 'Recent Items' menu on the Start menu, jump lists, and shortcuts at the bottom of the 'File' menu in applications. +Function DisableRecentFiles { + Write-Output "Disabling recent files lists..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoRecentDocsHistory" -Type DWord -Value 1 +} + +# Enable recent files lists +Function EnableRecentFiles { + Write-Output "Enabling recent files lists..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoRecentDocsHistory" -ErrorAction SilentlyContinue +} + +########## +#endregion Privacy Tweaks +########## + + + +########## +#region Security Tweaks +########## + +# Lower UAC level (disabling it completely would break apps) +Function SetUACLow { + Write-Output "Lowering UAC level..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "PromptOnSecureDesktop" -Type DWord -Value 0 +} + +# Raise UAC level +Function SetUACHigh { + Write-Output "Raising UAC level..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ConsentPromptBehaviorAdmin" -Type DWord -Value 5 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "PromptOnSecureDesktop" -Type DWord -Value 1 +} + +# Enable sharing mapped drives between users +Function EnableSharingMappedDrives { + Write-Output "Enabling sharing mapped drives between users..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLinkedConnections" -Type DWord -Value 1 +} + +# Disable sharing mapped drives between users +Function DisableSharingMappedDrives { + Write-Output "Disabling sharing mapped drives between users..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableLinkedConnections" -ErrorAction SilentlyContinue +} + +# Disable implicit administrative shares +Function DisableAdminShares { + Write-Output "Disabling implicit administrative shares..." + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" -Name "AutoShareWks" -Type DWord -Value 0 +} + +# Enable implicit administrative shares +Function EnableAdminShares { + Write-Output "Enabling implicit administrative shares..." + Remove-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" -Name "AutoShareWks" -ErrorAction SilentlyContinue +} + +# Disable Firewall +Function DisableFirewall { + Write-Output "Disabling Firewall..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfile")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfile" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfile" -Name "EnableFirewall" -Type DWord -Value 0 +} + +# Enable Firewall +Function EnableFirewall { + Write-Output "Enabling Firewall..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsFirewall\StandardProfile" -Name "EnableFirewall" -ErrorAction SilentlyContinue +} + +# Hide Windows Defender SysTray icon +Function HideDefenderTrayIcon { + Write-Output "Hiding Windows Defender SysTray icon..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Systray")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Systray" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Systray" -Name "HideSystray" -Type DWord -Value 1 + If ([System.Environment]::OSVersion.Version.Build -eq 14393) { + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "WindowsDefender" -ErrorAction SilentlyContinue + } ElseIf ([System.Environment]::OSVersion.Version.Build -ge 15063) { + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "SecurityHealth" -ErrorAction SilentlyContinue + } +} + +# Show Windows Defender SysTray icon +Function ShowDefenderTrayIcon { + Write-Output "Showing Windows Defender SysTray icon..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Systray" -Name "HideSystray" -ErrorAction SilentlyContinue + If ([System.Environment]::OSVersion.Version.Build -eq 14393) { + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "WindowsDefender" -Type ExpandString -Value "`"%ProgramFiles%\Windows Defender\MSASCuiL.exe`"" + } ElseIf ([System.Environment]::OSVersion.Version.Build -ge 15063 -And [System.Environment]::OSVersion.Version.Build -le 17134) { + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "SecurityHealth" -Type ExpandString -Value "%ProgramFiles%\Windows Defender\MSASCuiL.exe" + } ElseIf ([System.Environment]::OSVersion.Version.Build -ge 17763) { + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "SecurityHealth" -Type ExpandString -Value "%windir%\system32\SecurityHealthSystray.exe" + } +} + +# Disable Windows Defender +Function DisableDefender { + Write-Output "Disabling Windows Defender..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -Type DWord -Value 1 + If ([System.Environment]::OSVersion.Version.Build -eq 14393) { + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "WindowsDefender" -ErrorAction SilentlyContinue + } ElseIf ([System.Environment]::OSVersion.Version.Build -ge 15063) { + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "SecurityHealth" -ErrorAction SilentlyContinue + } +} + +# Enable Windows Defender +Function EnableDefender { + Write-Output "Enabling Windows Defender..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender" -Name "DisableAntiSpyware" -ErrorAction SilentlyContinue + If ([System.Environment]::OSVersion.Version.Build -eq 14393) { + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "WindowsDefender" -Type ExpandString -Value "`"%ProgramFiles%\Windows Defender\MSASCuiL.exe`"" + } ElseIf ([System.Environment]::OSVersion.Version.Build -ge 15063 -And [System.Environment]::OSVersion.Version.Build -le 17134) { + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "SecurityHealth" -Type ExpandString -Value "%ProgramFiles%\Windows Defender\MSASCuiL.exe" + } ElseIf ([System.Environment]::OSVersion.Version.Build -ge 17763) { + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" -Name "SecurityHealth" -Type ExpandString -Value "%windir%\system32\SecurityHealthSystray.exe" + } +} + +# Disable Windows Defender Cloud +Function DisableDefenderCloud { + Write-Output "Disabling Windows Defender Cloud..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -Type DWord -Value 2 +} + +# Enable Windows Defender Cloud +Function EnableDefenderCloud { + Write-Output "Enabling Windows Defender Cloud..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SpynetReporting" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -ErrorAction SilentlyContinue +} + +# Enable Controlled Folder Access (Defender Exploit Guard feature) - Applicable since 1709, requires Windows Defender to be enabled +Function EnableCtrldFolderAccess { + Write-Output "Enabling Controlled Folder Access..." + Set-MpPreference -EnableControlledFolderAccess Enabled -ErrorAction SilentlyContinue +} + +# Disable Controlled Folder Access (Defender Exploit Guard feature) - Applicable since 1709, requires Windows Defender to be enabled +Function DisableCtrldFolderAccess { + Write-Output "Disabling Controlled Folder Access..." + Set-MpPreference -EnableControlledFolderAccess Disabled -ErrorAction SilentlyContinue +} + +# Enable Core Isolation Memory Integrity - Part of Windows Defender System Guard virtualization-based security - Applicable since 1803 +Function EnableCIMemoryIntegrity { + Write-Output "Enabling Core Isolation Memory Integrity..." + If (!(Test-Path "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity")) { + New-Item -Path "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" -Name "Enabled" -Type DWord -Value 1 +} + +# Disable Core Isolation Memory Integrity - Applicable since 1803 +Function DisableCIMemoryIntegrity { + Write-Output "Disabling Core Isolation Memory Integrity..." + Remove-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\DeviceGuard\Scenarios\HypervisorEnforcedCodeIntegrity" -Name "Enabled" -ErrorAction SilentlyContinue +} + +# Enable Windows Defender Application Guard - Applicable since 1709 Enterprise and 1803 Pro. Not applicable to Server +# Not supported on VMs and VDI environment. Check requirements on https://docs.microsoft.com/en-us/windows/security/threat-protection/windows-defender-application-guard/reqs-wd-app-guard +Function EnableDefenderAppGuard { + Write-Output "Enabling Windows Defender Application Guard..." + Enable-WindowsOptionalFeature -online -FeatureName "Windows-Defender-ApplicationGuard" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Disable Windows Defender Application Guard - Applicable since 1709 Enterprise and 1803 Pro. Not applicable to Server +Function DisableDefenderAppGuard { + Write-Output "Disabling Windows Defender Application Guard..." + Disable-WindowsOptionalFeature -online -FeatureName "Windows-Defender-ApplicationGuard" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Hide Account Protection warning in Defender about not using a Microsoft account +Function HideAccountProtectionWarn { + Write-Output "Hiding Account Protection warning..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows Security Health\State")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows Security Health\State" -Force | Out-Null + } + Set-ItemProperty "HKCU:\Software\Microsoft\Windows Security Health\State" -Name "AccountProtection_MicrosoftAccount_Disconnected" -Type DWord -Value 1 +} + +# Show Account Protection warning in Defender +Function ShowAccountProtectionWarn { + Write-Output "Showing Account Protection warning..." + Remove-ItemProperty "HKCU:\Software\Microsoft\Windows Security Health\State" -Name "AccountProtection_MicrosoftAccount_Disconnected" -ErrorAction SilentlyContinue +} + +# Disable blocking of downloaded files (i.e. storing zone information - no need to do File\Properties\Unblock) +Function DisableDownloadBlocking { + Write-Output "Disabling blocking of downloaded files..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments" | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments" -Name "SaveZoneInformation" -Type DWord -Value 1 +} + +# Enable blocking of downloaded files +Function EnableDownloadBlocking { + Write-Output "Enabling blocking of downloaded files..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments" -Name "SaveZoneInformation" -ErrorAction SilentlyContinue +} + +# Disable Windows Script Host (execution of *.vbs scripts and alike) +Function DisableScriptHost { + Write-Output "Disabling Windows Script Host..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name "Enabled" -Type DWord -Value 0 +} + +# Enable Windows Script Host +Function EnableScriptHost { + Write-Output "Enabling Windows Script Host..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows Script Host\Settings" -Name "Enabled" -ErrorAction SilentlyContinue +} + +# Enable strong cryptography for .NET Framework (version 4 and above) +# https://stackoverflow.com/questions/36265534/invoke-webrequest-ssl-fails +Function EnableDotNetStrongCrypto { + Write-output "Enabling .NET strong cryptography..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\.NETFramework\v4.0.30319" -Name "SchUseStrongCrypto" -Type DWord -Value 1 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319" -Name "SchUseStrongCrypto" -Type DWord -Value 1 +} + +# Disable strong cryptography for .NET Framework (version 4 and above) +Function DisableDotNetStrongCrypto { + Write-output "Disabling .NET strong cryptography..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\.NETFramework\v4.0.30319" -Name "SchUseStrongCrypto" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\v4.0.30319" -Name "SchUseStrongCrypto" -ErrorAction SilentlyContinue +} + +# Enable Meltdown (CVE-2017-5754) compatibility flag - Required for January and February 2018 Windows updates +# This flag is normally automatically enabled by compatible antivirus software (such as Windows Defender). +# Use the tweak only if you have confirmed that your AV is compatible but unable to set the flag automatically or if you don't use any AV at all. +# As of March 2018, the compatibility check has been lifted for security updates. +# See https://support.microsoft.com/en-us/help/4072699/windows-security-updates-and-antivirus-software for details +Function EnableMeltdownCompatFlag { + Write-Output "Enabling Meltdown (CVE-2017-5754) compatibility flag..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat" -Name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -Type DWord -Value 0 +} + +# Disable Meltdown (CVE-2017-5754) compatibility flag +Function DisableMeltdownCompatFlag { + Write-Output "Disabling Meltdown (CVE-2017-5754) compatibility flag..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\QualityCompat" -Name "cadca5fe-87d3-4b96-b7fb-a231484277cc" -ErrorAction SilentlyContinue +} + +# Enable F8 boot menu options +Function EnableF8BootMenu { + Write-Output "Enabling F8 boot menu options..." + bcdedit /set `{current`} BootMenuPolicy Legacy | Out-Null +} + +# Disable F8 boot menu options +Function DisableF8BootMenu { + Write-Output "Disabling F8 boot menu options..." + bcdedit /set `{current`} BootMenuPolicy Standard | Out-Null +} + +# Disable automatic recovery mode during boot +# This causes boot process to always ignore startup errors and attempt to boot normally +# It is still possible to interrupt the boot and enter recovery mode manually. In order to disable even that, apply also DisableRecoveryAndReset tweak +Function DisableBootRecovery { + Write-Output "Disabling automatic recovery mode during boot..." + bcdedit /set `{current`} BootStatusPolicy IgnoreAllFailures | Out-Null +} + +# Enable automatic entering recovery mode during boot +# This allows the boot process to automatically enter recovery mode when it detects startup errors (default behavior) +Function EnableBootRecovery { + Write-Output "Enabling automatic recovery mode during boot..." + bcdedit /deletevalue `{current`} BootStatusPolicy | Out-Null +} + +# Disable System Recovery and Factory reset +# Warning: This tweak completely removes the option to enter the system recovery during boot and the possibility to perform a factory reset +Function DisableRecoveryAndReset { + Write-Output "Disabling System Recovery and Factory reset..." + reagentc /disable 2>&1 | Out-Null +} + +# Enable System Recovery and Factory reset +Function EnableRecoveryAndReset { + Write-Output "Enabling System Recovery and Factory reset..." + reagentc /enable 2>&1 | Out-Null +} + +# Set Data Execution Prevention (DEP) policy to OptOut (Turn on DEP for all programs and services except selected) +Function SetDEPOptOut { + Write-Output "Setting Data Execution Prevention (DEP) policy to OptOut..." + bcdedit /set `{current`} nx OptOut | Out-Null +} + +# Set Data Execution Prevention (DEP) policy to OptIn (Turn on DEP for essential Windows programs and services only) +Function SetDEPOptIn { + Write-Output "Setting Data Execution Prevention (DEP) policy to OptIn..." + bcdedit /set `{current`} nx OptIn | Out-Null +} + +########## +#endregion Security Tweaks +########## + + + +########## +#region Network Tweaks +########## + +# Set current network profile to private (allow file sharing, device discovery, etc.) +Function SetCurrentNetworkPrivate { + Write-Output "Setting current network profile to private..." + Set-NetConnectionProfile -NetworkCategory Private +} + +# Set current network profile to public (deny file sharing, device discovery, etc.) +Function SetCurrentNetworkPublic { + Write-Output "Setting current network profile to public..." + Set-NetConnectionProfile -NetworkCategory Public +} + +# Set unknown networks profile to private (allow file sharing, device discovery, etc.) +Function SetUnknownNetworksPrivate { + Write-Output "Setting unknown networks profile to private..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\010103000F0000F0010000000F0000F0C967A3643C3AD745950DA7859209176EF5B87C875FA20DF21951640E807D7C24")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\010103000F0000F0010000000F0000F0C967A3643C3AD745950DA7859209176EF5B87C875FA20DF21951640E807D7C24" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\010103000F0000F0010000000F0000F0C967A3643C3AD745950DA7859209176EF5B87C875FA20DF21951640E807D7C24" -Name "Category" -Type DWord -Value 1 +} + +# Set unknown networks profile to public (deny file sharing, device discovery, etc.) +Function SetUnknownNetworksPublic { + Write-Output "Setting unknown networks profile to public..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\NetworkList\Signatures\010103000F0000F0010000000F0000F0C967A3643C3AD745950DA7859209176EF5B87C875FA20DF21951640E807D7C24" -Name "Category" -ErrorAction SilentlyContinue +} + +# Disable automatic installation of network devices +Function DisableNetDevicesAutoInst { + Write-Output "Disabling automatic installation of network devices..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private" -Name "AutoSetup" -Type DWord -Value 0 +} + +# Enable automatic installation of network devices +Function EnableNetDevicesAutoInst { + Write-Output "Enabling automatic installation of network devices..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\NcdAutoSetup\Private" -Name "AutoSetup" -ErrorAction SilentlyContinue +} + +# Stop and disable Home Groups services - Not applicable since 1803. Not applicable to Server +Function DisableHomeGroups { + Write-Output "Stopping and disabling Home Groups services..." + If (Get-Service "HomeGroupListener" -ErrorAction SilentlyContinue) { + Stop-Service "HomeGroupListener" -WarningAction SilentlyContinue + Set-Service "HomeGroupListener" -StartupType Disabled + } + If (Get-Service "HomeGroupProvider" -ErrorAction SilentlyContinue) { + Stop-Service "HomeGroupProvider" -WarningAction SilentlyContinue + Set-Service "HomeGroupProvider" -StartupType Disabled + } +} + +# Enable and start Home Groups services - Not applicable since 1803. Not applicable to Server +Function EnableHomeGroups { + Write-Output "Starting and enabling Home Groups services..." + Set-Service "HomeGroupListener" -StartupType Manual + Set-Service "HomeGroupProvider" -StartupType Manual + Start-Service "HomeGroupProvider" -WarningAction SilentlyContinue +} + +# Disable obsolete SMB 1.0 protocol - Disabled by default since 1709 +Function DisableSMB1 { + Write-Output "Disabling SMB 1.0 protocol..." + Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force +} + +# Enable obsolete SMB 1.0 protocol - Disabled by default since 1709 +Function EnableSMB1 { + Write-Output "Enabling SMB 1.0 protocol..." + Set-SmbServerConfiguration -EnableSMB1Protocol $true -Force +} + +# Disable SMB Server - Completely disables file and printer sharing, but leaves the system able to connect to another SMB server as a client +# Note: Do not run this if you plan to use Docker and Shared Drives (as it uses SMB internally), see https://github.com/Disassembler0/Win10-Initial-Setup-Script/issues/216 +Function DisableSMBServer { + Write-Output "Disabling SMB Server..." + Set-SmbServerConfiguration -EnableSMB1Protocol $false -Force + Set-SmbServerConfiguration -EnableSMB2Protocol $false -Force + Disable-NetAdapterBinding -Name "*" -ComponentID "ms_server" +} + +# Enable SMB Server +Function EnableSMBServer { + Write-Output "Enabling SMB Server..." + Set-SmbServerConfiguration -EnableSMB2Protocol $true -Force + Enable-NetAdapterBinding -Name "*" -ComponentID "ms_server" +} + +# Disable NetBIOS over TCP/IP on all currently installed network interfaces +Function DisableNetBIOS { + Write-Output "Disabling NetBIOS over TCP/IP..." + Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\services\NetBT\Parameters\Interfaces\Tcpip*" -Name "NetbiosOptions" -Type DWord -Value 2 +} + +# Enable NetBIOS over TCP/IP on all currently installed network interfaces +Function EnableNetBIOS { + Write-Output "Enabling NetBIOS over TCP/IP..." + Set-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\services\NetBT\Parameters\Interfaces\Tcpip*" -Name "NetbiosOptions" -Type DWord -Value 0 +} + +# Disable Link-Local Multicast Name Resolution (LLMNR) protocol +Function DisableLLMNR { + Write-Output "Disabling Link-Local Multicast Name Resolution (LLMNR)..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" -Name "EnableMulticast" -Type DWord -Value 0 +} + +# Enable Link-Local Multicast Name Resolution (LLMNR) protocol +Function EnableLLMNR { + Write-Output "Enabling Link-Local Multicast Name Resolution (LLMNR)..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\DNSClient" -Name "EnableMulticast" -ErrorAction SilentlyContinue +} + +# Disable Local-Link Discovery Protocol (LLDP) for all installed network interfaces +Function DisableLLDP { + Write-Output "Disabling Local-Link Discovery Protocol (LLDP)..." + Disable-NetAdapterBinding -Name "*" -ComponentID "ms_lldp" +} + +# Enable Local-Link Discovery Protocol (LLDP) for all installed network interfaces +Function EnableLLDP { + Write-Output "Enabling Local-Link Discovery Protocol (LLDP)..." + Enable-NetAdapterBinding -Name "*" -ComponentID "ms_lldp" +} + +# Disable Local-Link Topology Discovery (LLTD) for all installed network interfaces +Function DisableLLTD { + Write-Output "Disabling Local-Link Topology Discovery (LLTD)..." + Disable-NetAdapterBinding -Name "*" -ComponentID "ms_lltdio" + Disable-NetAdapterBinding -Name "*" -ComponentID "ms_rspndr" +} + +# Enable Local-Link Topology Discovery (LLTD) for all installed network interfaces +Function EnableLLTD { + Write-Output "Enabling Local-Link Topology Discovery (LLTD)..." + Enable-NetAdapterBinding -Name "*" -ComponentID "ms_lltdio" + Enable-NetAdapterBinding -Name "*" -ComponentID "ms_rspndr" +} + +# Disable Client for Microsoft Networks for all installed network interfaces +Function DisableMSNetClient { + Write-Output "Disabling Client for Microsoft Networks..." + Disable-NetAdapterBinding -Name "*" -ComponentID "ms_msclient" +} + +# Enable Client for Microsoft Networks for all installed network interfaces +Function EnableMSNetClient { + Write-Output "Enabling Client for Microsoft Networks..." + Enable-NetAdapterBinding -Name "*" -ComponentID "ms_msclient" +} + +# Disable Quality of Service (QoS) packet scheduler for all installed network interfaces +Function DisableQoS { + Write-Output "Disabling Quality of Service (QoS) packet scheduler..." + Disable-NetAdapterBinding -Name "*" -ComponentID "ms_pacer" +} + +# Enable Quality of Service (QoS) packet scheduler for all installed network interfaces +Function EnableQoS { + Write-Output "Enabling Quality of Service (QoS) packet scheduler..." + Enable-NetAdapterBinding -Name "*" -ComponentID "ms_pacer" +} + +# Disable IPv4 stack for all installed network interfaces +Function DisableIPv4 { + Write-Output "Disabling IPv4 stack..." + Disable-NetAdapterBinding -Name "*" -ComponentID "ms_tcpip" +} + +# Enable IPv4 stack for all installed network interfaces +Function EnableIPv4 { + Write-Output "Enabling IPv4 stack..." + Enable-NetAdapterBinding -Name "*" -ComponentID "ms_tcpip" +} + +# Disable IPv6 stack for all installed network interfaces +Function DisableIPv6 { + Write-Output "Disabling IPv6 stack..." + Disable-NetAdapterBinding -Name "*" -ComponentID "ms_tcpip6" +} + +# Enable IPv6 stack for all installed network interfaces +Function EnableIPv6 { + Write-Output "Enabling IPv6 stack..." + Enable-NetAdapterBinding -Name "*" -ComponentID "ms_tcpip6" +} + +# Disable Network Connectivity Status Indicator active test +# Note: This may reduce the ability of OS and other components to determine internet access, however protects against a specific type of zero-click attack. +# See https://github.com/Disassembler0/Win10-Initial-Setup-Script/pull/111 for details +Function DisableNCSIProbe { + Write-Output "Disabling Network Connectivity Status Indicator (NCSI) active test..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\NetworkConnectivityStatusIndicator" -Name "NoActiveProbe" -Type DWord -Value 1 +} + +# Enable Network Connectivity Status Indicator active test +Function EnableNCSIProbe { + Write-Output "Enabling Network Connectivity Status Indicator (NCSI) active test..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\NetworkConnectivityStatusIndicator" -Name "NoActiveProbe" -ErrorAction SilentlyContinue +} + +# Disable Internet Connection Sharing (e.g. mobile hotspot) +Function DisableConnectionSharing { + Write-Output "Disabling Internet Connection Sharing..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Network Connections" -Name "NC_ShowSharedAccessUI" -Type DWord -Value 0 +} + +# Enable Internet Connection Sharing (e.g. mobile hotspot) +Function EnableConnectionSharing { + Write-Output "Enabling Internet Connection Sharing..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Network Connections" -Name "NC_ShowSharedAccessUI" -ErrorAction SilentlyContinue +} + +# Disable Remote Assistance - Not applicable to Server (unless Remote Assistance is explicitly installed) +Function DisableRemoteAssistance { + Write-Output "Disabling Remote Assistance..." + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Remote Assistance" -Name "fAllowToGetHelp" -Type DWord -Value 0 +} + +# Enable Remote Assistance - Not applicable to Server (unless Remote Assistance is explicitly installed) +Function EnableRemoteAssistance { + Write-Output "Enabling Remote Assistance..." + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Remote Assistance" -Name "fAllowToGetHelp" -Type DWord -Value 1 +} + +# Enable Remote Desktop +Function EnableRemoteDesktop { + Write-Output "Enabling Remote Desktop..." + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Type DWord -Value 0 + Enable-NetFirewallRule -Name "RemoteDesktop*" +} + +# Disable Remote Desktop +Function DisableRemoteDesktop { + Write-Output "Disabling Remote Desktop..." + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server" -Name "fDenyTSConnections" -Type DWord -Value 1 + Disable-NetFirewallRule -Name "RemoteDesktop*" +} + +########## +#endregion Network Tweaks +########## + + + +########## +#region Service Tweaks +########## + +# Disable offering of Malicious Software Removal Tool through Windows Update +Function DisableUpdateMSRT { + Write-Output "Disabling Malicious Software Removal Tool offering..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" -Name "DontOfferThroughWUAU" -Type DWord -Value 1 +} + +# Enable offering of Malicious Software Removal Tool through Windows Update +Function EnableUpdateMSRT { + Write-Output "Enabling Malicious Software Removal Tool offering..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MRT" -Name "DontOfferThroughWUAU" -ErrorAction SilentlyContinue +} + +# Disable offering of drivers through Windows Update +# Note: This doesn't work properly if you use a driver intended for another hardware model. E.g. Intel I219-V on WinServer works only with I219-LM driver. +# Therefore Windows update will repeatedly try and fail to install I219-V driver indefinitely even if you use the tweak. +Function DisableUpdateDriver { + Write-Output "Disabling driver offering through Windows Update..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Name "PreventDeviceMetadataFromNetwork" -Type DWord -Value 1 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontPromptForWindowsUpdate" -Type DWord -Value 1 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontSearchWindowsUpdate" -Type DWord -Value 1 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DriverUpdateWizardWuSearchEnabled" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ExcludeWUDriversInQualityUpdate" -Type DWord -Value 1 +} + +# Enable offering of drivers through Windows Update +Function EnableUpdateDriver { + Write-Output "Enabling driver offering through Windows Update..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Device Metadata" -Name "PreventDeviceMetadataFromNetwork" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontPromptForWindowsUpdate" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DontSearchWindowsUpdate" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DriverSearching" -Name "DriverUpdateWizardWuSearchEnabled" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate" -Name "ExcludeWUDriversInQualityUpdate" -ErrorAction SilentlyContinue +} + +# Enable receiving updates for other Microsoft products via Windows Update +Function EnableUpdateMSProducts { + Write-Output "Enabling updates for other Microsoft products..." + (New-Object -ComObject Microsoft.Update.ServiceManager).AddService2("7971f918-a847-4430-9279-4a52d1efe18d", 7, "") | Out-Null +} + +# Disable receiving updates for other Microsoft products via Windows Update +Function DisableUpdateMSProducts { + Write-Output "Disabling updates for other Microsoft products..." + If ((New-Object -ComObject Microsoft.Update.ServiceManager).Services | Where-Object { $_.ServiceID -eq "7971f918-a847-4430-9279-4a52d1efe18d"}) { + (New-Object -ComObject Microsoft.Update.ServiceManager).RemoveService("7971f918-a847-4430-9279-4a52d1efe18d") | Out-Null + } +} + +# Disable Windows Update automatic downloads +Function DisableUpdateAutoDownload { + Write-Output "Disabling Windows Update automatic downloads..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUOptions" -Type DWord -Value 2 +} + +# Enable Windows Update automatic downloads +Function EnableUpdateAutoDownload { + Write-Output "Enabling Windows Update automatic downloads..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUOptions" -ErrorAction SilentlyContinue +} + +# Disable automatic restart after Windows Update installation +# The tweak is slightly experimental, as it registers a dummy debugger for MusNotification.exe +# which blocks the restart prompt executable from running, thus never schedulling the restart +Function DisableUpdateRestart { + Write-Output "Disabling Windows Update automatic restart..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MusNotification.exe")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MusNotification.exe" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MusNotification.exe" -Name "Debugger" -Type String -Value "cmd.exe" +} + +# Enable automatic restart after Windows Update installation +Function EnableUpdateRestart { + Write-Output "Enabling Windows Update automatic restart..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MusNotification.exe" -Name "Debugger" -ErrorAction SilentlyContinue +} + +# Disable nightly wake-up for Automatic Maintenance and Windows Updates +Function DisableMaintenanceWakeUp { + Write-Output "Disabling nightly wake-up for Automatic Maintenance..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUPowerManagement" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\Maintenance" -Name "WakeUp" -Type DWord -Value 0 +} + +# Enable nightly wake-up for Automatic Maintenance and Windows Updates +Function EnableMaintenanceWakeUp { + Write-Output "Enabling nightly wake-up for Automatic Maintenance..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUPowerManagement" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Schedule\Maintenance" -Name "WakeUp" -ErrorAction SilentlyContinue +} + +# Disable Shared Experiences - Applicable since 1703. Not applicable to Server +# This setting can be set also via GPO, however doing so causes reset of Start Menu cache. See https://github.com/Disassembler0/Win10-Initial-Setup-Script/issues/145 for details +Function DisableSharedExperiences { + Write-Output "Disabling Shared Experiences..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\CDP")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\CDP" | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\CDP" -Name "RomeSdkChannelUserAuthzPolicy" -Type DWord -Value 0 +} + +# Enable Shared Experiences - Applicable since 1703. Not applicable to Server +Function EnableSharedExperiences { + Write-Output "Enabling Shared Experiences..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\CDP" -Name "RomeSdkChannelUserAuthzPolicy" -Type DWord -Value 1 +} + +# Enable Clipboard History - Applicable since 1809. Not applicable to Server +Function EnableClipboardHistory { + Write-Output "Enabling Clipboard History..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Clipboard" -Name "EnableClipboardHistory" -Type DWord -Value 1 +} + +# Disable Clipboard History - Applicable since 1809. Not applicable to Server +Function DisableClipboardHistory { + Write-Output "Disabling Clipboard History..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Clipboard" -Name "EnableClipboardHistory" -ErrorAction SilentlyContinue +} + +# Disable Autoplay +Function DisableAutoplay { + Write-Output "Disabling Autoplay..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name "DisableAutoplay" -Type DWord -Value 1 +} + +# Enable Autoplay +Function EnableAutoplay { + Write-Output "Enabling Autoplay..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name "DisableAutoplay" -Type DWord -Value 0 +} + +# Disable Autorun for all drives +Function DisableAutorun { + Write-Output "Disabling Autorun for all drives..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoDriveTypeAutoRun" -Type DWord -Value 255 +} + +# Enable Autorun for removable drives +Function EnableAutorun { + Write-Output "Enabling Autorun for all drives..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoDriveTypeAutoRun" -ErrorAction SilentlyContinue +} + +# Disable System Restore for system drive - Not applicable to Server +# Note: This does not delete already existing restore points as the deletion of restore points is irreversible. In order to do that, run also following command. +# vssadmin Delete Shadows /For=$env:SYSTEMDRIVE /Quiet +Function DisableRestorePoints { + Write-Output "Disabling System Restore for system drive..." + Disable-ComputerRestore -Drive "$env:SYSTEMDRIVE" +} + +# Enable System Restore for system drive - Not applicable to Server +# Note: Some systems (notably VMs) have maximum size allowed to be used for shadow copies set to zero. In order to increase the size, run following command. +# vssadmin Resize ShadowStorage /On=$env:SYSTEMDRIVE /For=$env:SYSTEMDRIVE /MaxSize=10GB +Function EnableRestorePoints { + Write-Output "Enabling System Restore for system drive..." + Enable-ComputerRestore -Drive "$env:SYSTEMDRIVE" +} + +# Enable Storage Sense - automatic disk cleanup - Applicable since 1703 +Function EnableStorageSense { + Write-Output "Enabling Storage Sense..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" -Name "01" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" -Name "StoragePoliciesNotified" -Type DWord -Value 1 +} + +# Disable Storage Sense - Applicable since 1703 +Function DisableStorageSense { + Write-Output "Disabling Storage Sense..." + Remove-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\StorageSense\Parameters\StoragePolicy" -Recurse -ErrorAction SilentlyContinue +} + +# Disable scheduled defragmentation task +Function DisableDefragmentation { + Write-Output "Disabling scheduled defragmentation..." + Disable-ScheduledTask -TaskName "Microsoft\Windows\Defrag\ScheduledDefrag" | Out-Null +} + +# Enable scheduled defragmentation task +Function EnableDefragmentation { + Write-Output "Enabling scheduled defragmentation..." + Enable-ScheduledTask -TaskName "Microsoft\Windows\Defrag\ScheduledDefrag" | Out-Null +} + +# Stop and disable Superfetch service +Function DisableSuperfetch { + Write-Output "Stopping and disabling Superfetch service..." + Stop-Service "SysMain" -WarningAction SilentlyContinue + Set-Service "SysMain" -StartupType Disabled +} + +# Start and enable Superfetch service +Function EnableSuperfetch { + Write-Output "Starting and enabling Superfetch service..." + Set-Service "SysMain" -StartupType Automatic + Start-Service "SysMain" -WarningAction SilentlyContinue +} + +# Stop and disable Windows Search indexing service +Function DisableIndexing { + Write-Output "Stopping and disabling Windows Search indexing service..." + Stop-Service "WSearch" -WarningAction SilentlyContinue + Set-Service "WSearch" -StartupType Disabled +} + +# Start and enable Windows Search indexing service +Function EnableIndexing { + Write-Output "Starting and enabling Windows Search indexing service..." + Set-Service "WSearch" -StartupType Automatic + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\WSearch" -Name "DelayedAutoStart" -Type DWord -Value 1 + Start-Service "WSearch" -WarningAction SilentlyContinue +} + +# Disable Modern UI swap file +# This disables creation and use of swapfile.sys and frees 256 MB of disk space. Swapfile.sys is used only by Modern UI apps. The tweak has no effect on the real swap in pagefile.sys. +Function DisableSwapFile { + Write-Output "Disabling Modern UI swap file..." + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" -Name "SwapfileControl" -Type Dword -Value 0 +} + +# Enable Modern UI swap file +Function EnableSwapFile { + Write-Output "Enabling Modern UI swap file..." + Remove-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" -Name "SwapfileControl" -ErrorAction SilentlyContinue +} + +# Disable Recycle Bin - Files will be permanently deleted without placing into Recycle Bin +Function DisableRecycleBin { + Write-Output "Disabling Recycle Bin..." + If (!(Test-Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer")) { + New-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" | Out-Null + } + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoRecycleFiles" -Type DWord -Value 1 +} + +# Enable Recycle Bin +Function EnableRecycleBin { + Write-Output "Enable Recycle Bin..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoRecycleFiles" -ErrorAction SilentlyContinue +} + +# Enable NTFS paths with length over 260 characters +Function EnableNTFSLongPaths { + Write-Output "Enabling NTFS paths with length over 260 characters..." + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Type DWord -Value 1 +} + +# Disable NTFS paths with length over 260 characters +Function DisableNTFSLongPaths { + Write-Output "Disabling NTFS paths with length over 260 characters..." + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Type DWord -Value 0 +} + +# Disable updating of NTFS last access timestamps +Function DisableNTFSLastAccess { + Write-Output "Disabling updating of NTFS last access timestamps..." + # User Managed, Last Access Updates Disabled + fsutil behavior set DisableLastAccess 1 | Out-Null +} + +# Enable updating of NTFS last access timestamps +Function EnableNTFSLastAccess { + Write-Output "Enabling updating of NTFS last access timestamps..." + If ([System.Environment]::OSVersion.Version.Build -ge 17134) { + # System Managed, Last Access Updates Enabled + fsutil behavior set DisableLastAccess 2 | Out-Null + } Else { + # Last Access Updates Enabled + fsutil behavior set DisableLastAccess 0 | Out-Null + } +} + +# Set BIOS time to UTC +Function SetBIOSTimeUTC { + Write-Output "Setting BIOS time to UTC..." + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" -Name "RealTimeIsUniversal" -Type DWord -Value 1 +} + +# Set BIOS time to local time +Function SetBIOSTimeLocal { + Write-Output "Setting BIOS time to Local time..." + Remove-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\TimeZoneInformation" -Name "RealTimeIsUniversal" -ErrorAction SilentlyContinue +} + +# 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) +Function EnableHibernation { + Write-Output "Enabling Hibernation..." + Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Session Manager\Power" -Name "HibernateEnabled" -Type DWord -Value 1 + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings" -Name "ShowHibernateOption" -Type DWord -Value 1 + powercfg /HIBERNATE ON 2>&1 | Out-Null +} + +# Disable Hibernation +Function DisableHibernation { + Write-Output "Disabling Hibernation..." + Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Session Manager\Power" -Name "HibernateEnabled" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings" -Name "ShowHibernateOption" -Type DWord -Value 0 + powercfg /HIBERNATE OFF 2>&1 | Out-Null +} + +# Disable Sleep start menu and keyboard button +Function DisableSleepButton { + Write-Output "Disabling Sleep start menu and keyboard button..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings" -Name "ShowSleepOption" -Type DWord -Value 0 + powercfg /SETACVALUEINDEX SCHEME_CURRENT SUB_BUTTONS SBUTTONACTION 0 + powercfg /SETDCVALUEINDEX SCHEME_CURRENT SUB_BUTTONS SBUTTONACTION 0 +} + +# Enable Sleep start menu and keyboard button +Function EnableSleepButton { + Write-Output "Enabling Sleep start menu and keyboard button..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FlyoutMenuSettings" -Name "ShowSleepOption" -Type DWord -Value 1 + powercfg /SETACVALUEINDEX SCHEME_CURRENT SUB_BUTTONS SBUTTONACTION 1 + powercfg /SETDCVALUEINDEX SCHEME_CURRENT SUB_BUTTONS SBUTTONACTION 1 +} + +# Disable display and sleep mode timeouts +Function DisableSleepTimeout { + Write-Output "Disabling display and sleep mode timeouts..." + powercfg /X monitor-timeout-ac 0 + powercfg /X monitor-timeout-dc 0 + powercfg /X standby-timeout-ac 0 + powercfg /X standby-timeout-dc 0 +} + +# Enable display and sleep mode timeouts +Function EnableSleepTimeout { + Write-Output "Enabling display and sleep mode timeouts..." + powercfg /X monitor-timeout-ac 10 + powercfg /X monitor-timeout-dc 5 + powercfg /X standby-timeout-ac 30 + powercfg /X standby-timeout-dc 15 +} + +# Disable Fast Startup +Function DisableFastStartup { + Write-Output "Disabling Fast Startup..." + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power" -Name "HiberbootEnabled" -Type DWord -Value 0 +} + +# Enable Fast Startup +Function EnableFastStartup { + Write-Output "Enabling Fast Startup..." + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power" -Name "HiberbootEnabled" -Type DWord -Value 1 +} + +# Disable automatic reboot on crash (BSOD) +Function DisableAutoRebootOnCrash { + Write-Output "Disabling automatic reboot on crash (BSOD)..." + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" -Name "AutoReboot" -Type DWord -Value 0 +} + +# Enable automatic reboot on crash (BSOD) +Function EnableAutoRebootOnCrash { + Write-Output "Enabling automatic reboot on crash (BSOD)..." + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl" -Name "AutoReboot" -Type DWord -Value 1 +} + +########## +#endregion Service Tweaks +########## + + + +########## +#region UI Tweaks +########## + +# Disable Action Center (Notification Center) +Function DisableActionCenter { + Write-Output "Disabling Action Center (Notification Center)..." + If (!(Test-Path "HKCU:\Software\Policies\Microsoft\Windows\Explorer")) { + New-Item -Path "HKCU:\Software\Policies\Microsoft\Windows\Explorer" | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\Explorer" -Name "DisableNotificationCenter" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications" -Name "ToastEnabled" -Type DWord -Value 0 +} + +# Enable Action Center (Notification Center) +Function EnableActionCenter { + Write-Output "Enabling Action Center (Notification Center)..." + Remove-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\Explorer" -Name "DisableNotificationCenter" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications" -Name "ToastEnabled" -ErrorAction SilentlyContinue +} + +# Disable Lock screen +Function DisableLockScreen { + Write-Output "Disabling Lock screen..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" -Name "NoLockScreen" -Type DWord -Value 1 +} + +# Enable Lock screen +Function EnableLockScreen { + Write-Output "Enabling Lock screen..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" -Name "NoLockScreen" -ErrorAction SilentlyContinue +} + +# Disable Lock screen - Anniversary Update workaround. The GPO used in DisableLockScreen has been broken in 1607 and fixed again in 1803 +Function DisableLockScreenRS1 { + Write-Output "Disabling Lock screen using scheduler workaround..." + $service = New-Object -com Schedule.Service + $service.Connect() + $task = $service.NewTask(0) + $task.Settings.DisallowStartIfOnBatteries = $false + $trigger = $task.Triggers.Create(9) + $trigger = $task.Triggers.Create(11) + $trigger.StateChange = 8 + $action = $task.Actions.Create(0) + $action.Path = "reg.exe" + $action.Arguments = "add HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\SessionData /t REG_DWORD /v AllowLockScreen /d 0 /f" + $service.GetFolder("\").RegisterTaskDefinition("Disable LockScreen", $task, 6, "NT AUTHORITY\SYSTEM", $null, 4) | Out-Null +} + +# Enable Lock screen - Anniversary Update workaround. The GPO used in DisableLockScreen has been broken in 1607 and fixed again in 1803 +Function EnableLockScreenRS1 { + Write-Output "Enabling Lock screen (removing scheduler workaround)..." + Unregister-ScheduledTask -TaskName "Disable LockScreen" -Confirm:$false -ErrorAction SilentlyContinue +} + +# Hide network options from Lock Screen +Function HideNetworkFromLockScreen { + Write-Output "Hiding network options from Lock Screen..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "DontDisplayNetworkSelectionUI" -Type DWord -Value 1 +} + +# Show network options on lock screen +Function ShowNetworkOnLockScreen { + Write-Output "Showing network options on Lock Screen..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "DontDisplayNetworkSelectionUI" -ErrorAction SilentlyContinue +} + +# Hide shutdown options from Lock Screen +Function HideShutdownFromLockScreen { + Write-Output "Hiding shutdown options from Lock Screen..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ShutdownWithoutLogon" -Type DWord -Value 0 +} + +# Show shutdown options on lock screen +Function ShowShutdownOnLockScreen { + Write-Output "Showing shutdown options on Lock Screen..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "ShutdownWithoutLogon" -Type DWord -Value 1 +} + +# Disable Lock screen Blur - Applicable since 1903 +Function DisableLockScreenBlur { + Write-Output "Disabling Lock screen Blur..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "DisableAcrylicBackgroundOnLogon" -Type DWord -Value 1 +} + +# Enable Lock screen Blur - Applicable since 1903 +Function EnableLockScreenBlur { + Write-Output "Enabling Lock screen Blur..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Name "DisableAcrylicBackgroundOnLogon" -ErrorAction SilentlyContinue +} + +# Disable Aero Shake (minimizing other windows when one is dragged by mouse and shaken) +Function DisableAeroShake { + Write-Output "Disabling Aero Shake..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "DisallowShaking" -Type DWord -Value 1 +} + +# Enable Aero Shake +Function EnableAeroShake { + Write-Output "Enabling Aero Shake..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "DisallowShaking" -ErrorAction SilentlyContinue +} + +# Disable accessibility keys prompts (Sticky keys, Toggle keys, Filter keys) +Function DisableAccessibilityKeys { + Write-Output "Disabling accessibility keys prompts..." + Set-ItemProperty -Path "HKCU:\Control Panel\Accessibility\StickyKeys" -Name "Flags" -Type String -Value "506" + Set-ItemProperty -Path "HKCU:\Control Panel\Accessibility\ToggleKeys" -Name "Flags" -Type String -Value "58" + Set-ItemProperty -Path "HKCU:\Control Panel\Accessibility\Keyboard Response" -Name "Flags" -Type String -Value "122" +} + +# Enable accessibility keys prompts (Sticky keys, Toggle keys, Filter keys) +Function EnableAccessibilityKeys { + Write-Output "Enabling accessibility keys prompts..." + Set-ItemProperty -Path "HKCU:\Control Panel\Accessibility\StickyKeys" -Name "Flags" -Type String -Value "510" + Set-ItemProperty -Path "HKCU:\Control Panel\Accessibility\ToggleKeys" -Name "Flags" -Type String -Value "62" + Set-ItemProperty -Path "HKCU:\Control Panel\Accessibility\Keyboard Response" -Name "Flags" -Type String -Value "126" +} + +# Show Task Manager details - Applicable since 1607 +# Although this functionality exist even in earlier versions, the Task Manager's behavior is different there and is not compatible with this tweak +Function ShowTaskManagerDetails { + Write-Output "Showing task manager details..." + $taskmgr = Start-Process -WindowStyle Hidden -FilePath taskmgr.exe -PassThru + $timeout = 30000 + $sleep = 100 + Do { + Start-Sleep -Milliseconds $sleep + $timeout -= $sleep + $preferences = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -ErrorAction SilentlyContinue + } Until ($preferences -or $timeout -le 0) + Stop-Process $taskmgr + If ($preferences) { + $preferences.Preferences[28] = 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -Type Binary -Value $preferences.Preferences + } +} + +# Hide Task Manager details - Applicable since 1607 +Function HideTaskManagerDetails { + Write-Output "Hiding task manager details..." + $preferences = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -ErrorAction SilentlyContinue + If ($preferences) { + $preferences.Preferences[28] = 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\TaskManager" -Name "Preferences" -Type Binary -Value $preferences.Preferences + } +} + +# Show file operations details +Function ShowFileOperationsDetails { + Write-Output "Showing file operations details..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager" | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager" -Name "EnthusiastMode" -Type DWord -Value 1 +} + +# Hide file operations details +Function HideFileOperationsDetails { + Write-Output "Hiding file operations details..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\OperationStatusManager" -Name "EnthusiastMode" -ErrorAction SilentlyContinue +} + +# Enable file delete confirmation dialog +Function EnableFileDeleteConfirm { + Write-Output "Enabling file delete confirmation dialog..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "ConfirmFileDelete" -Type DWord -Value 1 +} + +# Disable file delete confirmation dialog +Function DisableFileDeleteConfirm { + Write-Output "Disabling file delete confirmation dialog..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "ConfirmFileDelete" -ErrorAction SilentlyContinue +} + +# Hide Taskbar Search icon / box +Function HideTaskbarSearch { + Write-Output "Hiding Taskbar Search icon / box..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "SearchboxTaskbarMode" -Type DWord -Value 0 +} + +# Show Taskbar Search icon +Function ShowTaskbarSearchIcon { + Write-Output "Showing Taskbar Search icon..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "SearchboxTaskbarMode" -Type DWord -Value 1 +} + +# Show Taskbar Search box +Function ShowTaskbarSearchBox { + Write-Output "Showing Taskbar Search box..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "SearchboxTaskbarMode" -Type DWord -Value 2 +} + +# Hide Task View button +Function HideTaskView { + Write-Output "Hiding Task View button..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Type DWord -Value 0 +} + +# Show Task View button +Function ShowTaskView { + Write-Output "Showing Task View button..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -ErrorAction SilentlyContinue +} + +# Show small icons in taskbar +Function ShowSmallTaskbarIcons { + Write-Output "Showing small icons in taskbar..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarSmallIcons" -Type DWord -Value 1 +} + +# Show large icons in taskbar +Function ShowLargeTaskbarIcons { + Write-Output "Showing large icons in taskbar..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarSmallIcons" -ErrorAction SilentlyContinue +} + +# Set taskbar buttons to show labels and combine when taskbar is full +Function SetTaskbarCombineWhenFull { + Write-Output "Setting taskbar buttons to combine when taskbar is full..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarGlomLevel" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "MMTaskbarGlomLevel" -Type DWord -Value 1 +} + +# Set taskbar buttons to show labels and never combine +Function SetTaskbarCombineNever { + Write-Output "Setting taskbar buttons to never combine..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarGlomLevel" -Type DWord -Value 2 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "MMTaskbarGlomLevel" -Type DWord -Value 2 +} + +# Set taskbar buttons to always combine and hide labels +Function SetTaskbarCombineAlways { + Write-Output "Setting taskbar buttons to always combine, hide labels..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarGlomLevel" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "MMTaskbarGlomLevel" -ErrorAction SilentlyContinue +} + +# Hide Taskbar People icon +Function HideTaskbarPeopleIcon { + Write-Output "Hiding People icon..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name "PeopleBand" -Type DWord -Value 0 +} + +# Show Taskbar People icon +Function ShowTaskbarPeopleIcon { + Write-Output "Showing People icon..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name "PeopleBand" -ErrorAction SilentlyContinue +} + +# Show all tray icons +Function ShowTrayIcons { + Write-Output "Showing all tray icons..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoAutoTrayNotify" -Type DWord -Value 1 +} + +# Hide tray icons as needed +Function HideTrayIcons { + Write-Output "Hiding tray icons..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoAutoTrayNotify" -ErrorAction SilentlyContinue +} + +# Show seconds in taskbar +Function ShowSecondsInTaskbar { + Write-Output "Showing seconds in taskbar..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowSecondsInSystemClock" -Type DWord -Value 1 +} + +# Hide seconds from taskbar +Function HideSecondsFromTaskbar { + Write-Output "Hiding seconds from taskbar..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowSecondsInSystemClock" -ErrorAction SilentlyContinue +} + +# Disable search for app in store for unknown extensions +Function DisableSearchAppInStore { + Write-Output "Disabling search for app in store for unknown extensions..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Name "NoUseStoreOpenWith" -Type DWord -Value 1 +} + +# Enable search for app in store for unknown extensions +Function EnableSearchAppInStore { + Write-Output "Enabling search for app in store for unknown extensions..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Name "NoUseStoreOpenWith" -ErrorAction SilentlyContinue +} + +# Disable 'How do you want to open this file?' prompt +Function DisableNewAppPrompt { + Write-Output "Disabling 'How do you want to open this file?' prompt..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Name "NoNewAppAlert" -Type DWord -Value 1 +} + +# Enable 'How do you want to open this file?' prompt +Function EnableNewAppPrompt { + Write-Output "Enabling 'How do you want to open this file?' prompt..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Name "NoNewAppAlert" -ErrorAction SilentlyContinue +} + +# Hide 'Recently added' list from the Start Menu +Function HideRecentlyAddedApps { + Write-Output "Hiding 'Recently added' list from the Start Menu..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Name "HideRecentlyAddedApps" -Type DWord -Value 1 +} + +# Show 'Recently added' list in the Start Menu +Function ShowRecentlyAddedApps { + Write-Output "Showing 'Recently added' list in the Start Menu..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Explorer" -Name "HideRecentlyAddedApps" -ErrorAction SilentlyContinue +} + +# Hide 'Most used' apps list from the Start Menu - Applicable until 1703 (hidden by default since then) +Function HideMostUsedApps { + Write-Output "Hiding 'Most used' apps list from the Start Menu..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoStartMenuMFUprogramsList" -Type DWord -Value 1 +} + +# Show 'Most used' apps list in the Start Menu - Applicable until 1703 (GPO broken since then) +Function ShowMostUsedApps { + Write-Output "Showing 'Most used' apps list in the Start Menu..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "NoStartMenuMFUprogramsList" -ErrorAction SilentlyContinue +} + +# Set Control Panel view to Small icons (Classic) +Function SetControlPanelSmallIcons { + Write-Output "Setting Control Panel view to small icons..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" -Name "StartupPage" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" -Name "AllItemsIconView" -Type DWord -Value 1 +} + +# Set Control Panel view to Large icons (Classic) +Function SetControlPanelLargeIcons { + Write-Output "Setting Control Panel view to large icons..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" -Name "StartupPage" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" -Name "AllItemsIconView" -Type DWord -Value 0 +} + +# Set Control Panel view to categories +Function SetControlPanelCategories { + Write-Output "Setting Control Panel view to categories..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" -Name "StartupPage" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" -Name "AllItemsIconView" -ErrorAction SilentlyContinue +} + +# Disable adding '- shortcut' to shortcut name +Function DisableShortcutInName { + Write-Output "Disabling adding '- shortcut' to shortcut name..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name "link" -Type Binary -Value ([byte[]](0,0,0,0)) +} + +# Enable adding '- shortcut' to shortcut name +Function EnableShortcutInName { + Write-Output "Enabling adding '- shortcut' to shortcut name..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name "link" -ErrorAction SilentlyContinue +} + +# Hide shortcut icon arrow +Function HideShortcutArrow { + Write-Output "Hiding shortcut icon arrow..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons" -Name "29" -Type String -Value "%SystemRoot%\System32\imageres.dll,-1015" +} + +# Show shortcut icon arrow +Function ShowShortcutArrow { + Write-Output "Showing shortcut icon arrow..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Icons" -Name "29" -ErrorAction SilentlyContinue +} + +# Adjusts visual effects for performance - Disables animations, transparency etc. but leaves font smoothing and miniatures enabled +Function SetVisualFXPerformance { + Write-Output "Adjusting visual effects for performance..." + Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "DragFullWindows" -Type String -Value 0 + Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "MenuShowDelay" -Type String -Value 0 + Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "UserPreferencesMask" -Type Binary -Value ([byte[]](144,18,3,128,16,0,0,0)) + Set-ItemProperty -Path "HKCU:\Control Panel\Desktop\WindowMetrics" -Name "MinAnimate" -Type String -Value 0 + Set-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name "KeyboardDelay" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewAlphaSelect" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewShadow" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAnimations" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" -Name "VisualFXSetting" -Type DWord -Value 3 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\DWM" -Name "EnableAeroPeek" -Type DWord -Value 0 +} + +# Adjusts visual effects for appearance +Function SetVisualFXAppearance { + Write-Output "Adjusting visual effects for appearance..." + Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "DragFullWindows" -Type String -Value 1 + Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "MenuShowDelay" -Type String -Value 400 + Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "UserPreferencesMask" -Type Binary -Value ([byte[]](158,30,7,128,18,0,0,0)) + Set-ItemProperty -Path "HKCU:\Control Panel\Desktop\WindowMetrics" -Name "MinAnimate" -Type String -Value 1 + Set-ItemProperty -Path "HKCU:\Control Panel\Keyboard" -Name "KeyboardDelay" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewAlphaSelect" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ListviewShadow" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAnimations" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" -Name "VisualFXSetting" -Type DWord -Value 3 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\DWM" -Name "EnableAeroPeek" -Type DWord -Value 1 +} + +# Enable window title bar color according to prevalent background color +Function EnableTitleBarColor { + Write-Output "Enabling window title bar color..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\DWM" -Name "ColorPrevalence" -Type DWord -Value 1 +} + +# Disable window title bar color +Function DisableTitleBarColor { + Write-Output "Disabling window title bar color..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\DWM" -Name "ColorPrevalence" -Type DWord -Value 0 +} + +# Enable Dark Theme +Function EnableDarkTheme { + Write-Output "Enabling Dark Theme..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "AppsUseLightTheme" -Type DWord -Value 0 +} + +# Disable Dark Theme +Function DisableDarkTheme { + Write-Output "Disabling Dark Theme..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize" -Name "AppsUseLightTheme" -ErrorAction SilentlyContinue +} + +# Add secondary en-US keyboard +Function AddENKeyboard { + Write-Output "Adding secondary en-US keyboard..." + $langs = Get-WinUserLanguageList + $langs.Add("en-US") + Set-WinUserLanguageList $langs -Force +} + +# Remove secondary en-US keyboard +Function RemoveENKeyboard { + Write-Output "Removing secondary en-US keyboard..." + $langs = Get-WinUserLanguageList + Set-WinUserLanguageList ($langs | Where-Object {$_.LanguageTag -ne "en-US"}) -Force +} + +# Enable NumLock after startup +Function EnableNumlock { + Write-Output "Enabling NumLock after startup..." + If (!(Test-Path "HKU:")) { + New-PSDrive -Name "HKU" -PSProvider "Registry" -Root "HKEY_USERS" | Out-Null + } + Set-ItemProperty -Path "HKU:\.DEFAULT\Control Panel\Keyboard" -Name "InitialKeyboardIndicators" -Type DWord -Value 2147483650 + Add-Type -AssemblyName System.Windows.Forms + If (!([System.Windows.Forms.Control]::IsKeyLocked('NumLock'))) { + $wsh = New-Object -ComObject WScript.Shell + $wsh.SendKeys('{NUMLOCK}') + } +} + +# Disable NumLock after startup +Function DisableNumlock { + Write-Output "Disabling NumLock after startup..." + If (!(Test-Path "HKU:")) { + New-PSDrive -Name "HKU" -PSProvider "Registry" -Root "HKEY_USERS" | Out-Null + } + Set-ItemProperty -Path "HKU:\.DEFAULT\Control Panel\Keyboard" -Name "InitialKeyboardIndicators" -Type DWord -Value 2147483648 + Add-Type -AssemblyName System.Windows.Forms + If ([System.Windows.Forms.Control]::IsKeyLocked('NumLock')) { + $wsh = New-Object -ComObject WScript.Shell + $wsh.SendKeys('{NUMLOCK}') + } +} + +# Disable enhanced pointer precision +Function DisableEnhPointerPrecision { + Write-Output "Disabling enhanced pointer precision..." + Set-ItemProperty -Path "HKCU:\Control Panel\Mouse" -Name "MouseSpeed" -Type String -Value "0" + Set-ItemProperty -Path "HKCU:\Control Panel\Mouse" -Name "MouseThreshold1" -Type String -Value "0" + Set-ItemProperty -Path "HKCU:\Control Panel\Mouse" -Name "MouseThreshold2" -Type String -Value "0" +} + +# Enable enhanced pointer precision +Function EnableEnhPointerPrecision { + Write-Output "Enabling enhanced pointer precision..." + Set-ItemProperty -Path "HKCU:\Control Panel\Mouse" -Name "MouseSpeed" -Type String -Value "1" + Set-ItemProperty -Path "HKCU:\Control Panel\Mouse" -Name "MouseThreshold1" -Type String -Value "6" + Set-ItemProperty -Path "HKCU:\Control Panel\Mouse" -Name "MouseThreshold2" -Type String -Value "10" +} + +# Set sound scheme to No Sounds +Function SetSoundSchemeNone { + Write-Output "Setting sound scheme to No Sounds..." + $SoundScheme = ".None" + Get-ChildItem -Path "HKCU:\AppEvents\Schemes\Apps\*\*" | ForEach-Object { + # If scheme keys do not exist in an event, create empty ones (similar behavior to Sound control panel). + If (!(Test-Path "$($_.PsPath)\$($SoundScheme)")) { + New-Item -Path "$($_.PsPath)\$($SoundScheme)" | Out-Null + } + If (!(Test-Path "$($_.PsPath)\.Current")) { + New-Item -Path "$($_.PsPath)\.Current" | Out-Null + } + # Get a regular string from any possible kind of value, i.e. resolve REG_EXPAND_SZ, copy REG_SZ or empty from non-existing. + $Data = (Get-ItemProperty -Path "$($_.PsPath)\$($SoundScheme)" -Name "(Default)" -ErrorAction SilentlyContinue)."(Default)" + # Replace any kind of value with a regular string (similar behavior to Sound control panel). + Set-ItemProperty -Path "$($_.PsPath)\$($SoundScheme)" -Name "(Default)" -Type String -Value $Data + # Copy data from source scheme to current. + Set-ItemProperty -Path "$($_.PsPath)\.Current" -Name "(Default)" -Type String -Value $Data + } + Set-ItemProperty -Path "HKCU:\AppEvents\Schemes" -Name "(Default)" -Type String -Value $SoundScheme +} + +# Set sound scheme to Windows Default +Function SetSoundSchemeDefault { + Write-Output "Setting sound scheme to Windows Default..." + $SoundScheme = ".Default" + Get-ChildItem -Path "HKCU:\AppEvents\Schemes\Apps\*\*" | ForEach-Object { + # If scheme keys do not exist in an event, create empty ones (similar behavior to Sound control panel). + If (!(Test-Path "$($_.PsPath)\$($SoundScheme)")) { + New-Item -Path "$($_.PsPath)\$($SoundScheme)" | Out-Null + } + If (!(Test-Path "$($_.PsPath)\.Current")) { + New-Item -Path "$($_.PsPath)\.Current" | Out-Null + } + # Get a regular string from any possible kind of value, i.e. resolve REG_EXPAND_SZ, copy REG_SZ or empty from non-existing. + $Data = (Get-ItemProperty -Path "$($_.PsPath)\$($SoundScheme)" -Name "(Default)" -ErrorAction SilentlyContinue)."(Default)" + # Replace any kind of value with a regular string (similar behavior to Sound control panel). + Set-ItemProperty -Path "$($_.PsPath)\$($SoundScheme)" -Name "(Default)" -Type String -Value $Data + # Copy data from source scheme to current. + Set-ItemProperty -Path "$($_.PsPath)\.Current" -Name "(Default)" -Type String -Value $Data + } + Set-ItemProperty -Path "HKCU:\AppEvents\Schemes" -Name "(Default)" -Type String -Value $SoundScheme +} + +# Disable playing Windows Startup sound +Function DisableStartupSound { + Write-Output "Disabling Windows Startup sound..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\BootAnimation" -Name "DisableStartupSound" -Type DWord -Value 1 +} + +# Enable playing Windows Startup sound +Function EnableStartupSound { + Write-Output "Enabling Windows Startup sound..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\BootAnimation" -Name "DisableStartupSound" -Type DWord -Value 0 +} + +# Disable changing sound scheme +Function DisableChangingSoundScheme { + Write-Output "Disabling changing sound scheme..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" -Name "NoChangingSoundScheme" -Type DWord -Value 1 +} + +# Enable changing sound scheme +Function EnableChangingSoundScheme { + Write-Output "Enabling changing sound scheme..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization" -Name "NoChangingSoundScheme" -ErrorAction SilentlyContinue +} + +# Enable verbose startup/shutdown status messages +Function EnableVerboseStatus { + Write-Output "Enabling verbose startup/shutdown status messages..." + If ((Get-CimInstance -Class "Win32_OperatingSystem").ProductType -eq 1) { + Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "VerboseStatus" -Type DWord -Value 1 + } Else { + Remove-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "VerboseStatus" -ErrorAction SilentlyContinue + } +} + +# Disable verbose startup/shutdown status messages +Function DisableVerboseStatus { + Write-Output "Disabling verbose startup/shutdown status messages..." + If ((Get-CimInstance -Class "Win32_OperatingSystem").ProductType -eq 1) { + Remove-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "VerboseStatus" -ErrorAction SilentlyContinue + } Else { + Set-ItemProperty -Path "HKLM:\Software\Microsoft\Windows\CurrentVersion\Policies\System" -Name "VerboseStatus" -Type DWord -Value 0 + } +} + +# Disable F1 Help key in Explorer and on the Desktop +Function DisableF1HelpKey { + Write-Output "Disabling F1 Help key..." + If (!(Test-Path "HKCU:\Software\Classes\TypeLib\{8cec5860-07a1-11d9-b15e-000d56bfe6ee}\1.0\0\win32")) { + New-Item -Path "HKCU:\Software\Classes\TypeLib\{8cec5860-07a1-11d9-b15e-000d56bfe6ee}\1.0\0\win32" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Classes\TypeLib\{8cec5860-07a1-11d9-b15e-000d56bfe6ee}\1.0\0\win32" -Name "(Default)" -Type "String" -Value "" + If (!(Test-Path "HKCU:\Software\Classes\TypeLib\{8cec5860-07a1-11d9-b15e-000d56bfe6ee}\1.0\0\win64")) { + New-Item -Path "HKCU:\Software\Classes\TypeLib\{8cec5860-07a1-11d9-b15e-000d56bfe6ee}\1.0\0\win64" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Classes\TypeLib\{8cec5860-07a1-11d9-b15e-000d56bfe6ee}\1.0\0\win64" -Name "(Default)" -Type "String" -Value "" +} + +# Enable F1 Help key in Explorer and on the Desktop +Function EnableF1HelpKey { + Write-Output "Enabling F1 Help key..." + Remove-Item "HKCU:\Software\Classes\TypeLib\{8cec5860-07a1-11d9-b15e-000d56bfe6ee}\1.0\0" -Recurse -ErrorAction SilentlyContinue +} + +########## +#endregion UI Tweaks +########## + + + +########## +#region Explorer UI Tweaks +########## + +# Show full directory path in Explorer title bar +Function ShowExplorerTitleFullPath { + Write-Output "Showing full directory path in Explorer title bar..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState" -Name "FullPath" -Type DWord -Value 1 +} + +# Hide full directory path in Explorer title bar, only directory name will be shown +Function HideExplorerTitleFullPath { + Write-Output "Hiding full directory path in Explorer title bar..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\CabinetState" -Name "FullPath" -ErrorAction SilentlyContinue +} + +# Show known file extensions +Function ShowKnownExtensions { + Write-Output "Showing known file extensions..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideFileExt" -Type DWord -Value 0 +} + +# Hide known file extensions +Function HideKnownExtensions { + Write-Output "Hiding known file extensions..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideFileExt" -Type DWord -Value 1 +} + +# Show hidden files +Function ShowHiddenFiles { + Write-Output "Showing hidden files..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Hidden" -Type DWord -Value 1 +} + +# Hide hidden files +Function HideHiddenFiles { + Write-Output "Hiding hidden files..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Hidden" -Type DWord -Value 2 +} + +# Show protected operating system files +Function ShowSuperHiddenFiles { + Write-Output "Showing protected operating system files..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowSuperHidden" -Type DWord -Value 1 +} + +# Hide protected operating system files +Function HideSuperHiddenFiles { + Write-Output "Hiding protected operating system files..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowSuperHidden" -Type DWord -Value 0 +} + +# Show empty drives (with no media) +Function ShowEmptyDrives { + Write-Output "Showing empty drives (with no media)..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideDrivesWithNoMedia" -Type DWord -Value 0 +} + +# Hide empty drives (with no media) +Function HideEmptyDrives { + Write-Output "Hiding empty drives (with no media)..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideDrivesWithNoMedia" -ErrorAction SilentlyContinue +} + +# Show folder merge conflicts +Function ShowFolderMergeConflicts { + Write-Output "Showing folder merge conflicts..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideMergeConflicts" -Type DWord -Value 0 +} + +# Hide folder merge conflicts +Function HideFolderMergeConflicts { + Write-Output "Hiding folder merge conflicts..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideMergeConflicts" -ErrorAction SilentlyContinue +} + +# Enable Explorer navigation pane expanding to current folder +Function EnableNavPaneExpand { + Write-Output "Enabling navigation pane expanding to current folder..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "NavPaneExpandToCurrentFolder" -Type DWord -Value 1 +} + +# Disable Explorer navigation pane expanding to current folder +Function DisableNavPaneExpand { + Write-Output "Disabling navigation pane expanding to current folder..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "NavPaneExpandToCurrentFolder" -ErrorAction SilentlyContinue +} + +# Show all folders in Explorer navigation pane +Function ShowNavPaneAllFolders { + Write-Output "Showing all folders in Explorer navigation pane..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "NavPaneShowAllFolders" -Type DWord -Value 1 +} + +# Hide all folders in Explorer navigation pane except the basic ones (Quick access, OneDrive, This PC, Network), some of which can be disabled using other tweaks +Function HideNavPaneAllFolders { + Write-Output "Hiding all folders in Explorer navigation pane (except the basic ones)..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "NavPaneShowAllFolders" -ErrorAction SilentlyContinue +} + +# Enable launching folder windows in a separate process +Function EnableFldrSeparateProcess { + Write-Output "Enabling launching folder windows in a separate process..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "SeparateProcess" -Type DWord -Value 1 +} + +# Disable launching folder windows in a separate process +Function DisableFldrSeparateProcess { + Write-Output "Disabling launching folder windows in a separate process..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "SeparateProcess" -Type DWord -Value 0 +} + +# Enable restoring previous folder windows at logon +Function EnableRestoreFldrWindows { + Write-Output "Enabling restoring previous folder windows at logon..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "PersistBrowsers" -Type DWord -Value 1 +} + +# Disable restoring previous folder windows at logon +Function DisableRestoreFldrWindows { + Write-Output "Disabling restoring previous folder windows at logon..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "PersistBrowsers" -ErrorAction SilentlyContinue +} + +# Show coloring of encrypted or compressed NTFS files (green for encrypted, blue for compressed) +Function ShowEncCompFilesColor { + Write-Output "Showing coloring of encrypted or compressed NTFS files..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowEncryptCompressedColor" -Type DWord -Value 1 +} + +# Hide coloring of encrypted or compressed NTFS files +Function HideEncCompFilesColor { + Write-Output "Hiding coloring of encrypted or compressed NTFS files..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowEncryptCompressedColor" -ErrorAction SilentlyContinue +} + +# Disable Sharing Wizard +Function DisableSharingWizard { + Write-Output "Disabling Sharing Wizard..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "SharingWizardOn" -Type DWord -Value 0 +} + +# Enable Sharing Wizard +Function EnableSharingWizard { + Write-Output "Enabling Sharing Wizard..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "SharingWizardOn" -ErrorAction SilentlyContinue +} + +# Hide item selection checkboxes +Function HideSelectCheckboxes { + Write-Output "Hiding item selection checkboxes..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "AutoCheckSelect" -Type DWord -Value 0 +} + +# Show item selection checkboxes +Function ShowSelectCheckboxes { + Write-Output "Showing item selection checkboxes..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "AutoCheckSelect" -Type DWord -Value 1 +} + +# Hide sync provider notifications +Function HideSyncNotifications { + Write-Output "Hiding sync provider notifications..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowSyncProviderNotifications" -Type DWord -Value 0 +} + +# Show sync provider notifications +Function ShowSyncNotifications { + Write-Output "Showing sync provider notifications..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowSyncProviderNotifications" -Type DWord -Value 1 +} + +# Hide recently and frequently used item shortcuts in Explorer +# Note: This is only UI tweak to hide the shortcuts. In order to stop creating most recently used (MRU) items lists everywhere, use privacy tweak 'DisableRecentFiles' instead. +Function HideRecentShortcuts { + Write-Output "Hiding recent shortcuts in Explorer..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name "ShowRecent" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name "ShowFrequent" -Type DWord -Value 0 +} + +# Show recently and frequently used item shortcuts in Explorer +Function ShowRecentShortcuts { + Write-Output "Showing recent shortcuts in Explorer..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name "ShowRecent" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name "ShowFrequent" -ErrorAction SilentlyContinue +} + +# Change default Explorer view to This PC +Function SetExplorerThisPC { + Write-Output "Changing default Explorer view to This PC..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "LaunchTo" -Type DWord -Value 1 +} + +# Change default Explorer view to Quick Access +Function SetExplorerQuickAccess { + Write-Output "Changing default Explorer view to Quick Access..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "LaunchTo" -ErrorAction SilentlyContinue +} + +# Hide Quick Access from Explorer navigation pane +Function HideQuickAccess { + Write-Output "Hiding Quick Access from Explorer navigation pane..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "HubMode" -Type DWord -Value 1 +} + +# Show Quick Access in Explorer navigation pane +Function ShowQuickAccess { + Write-Output "Showing Quick Access in Explorer navigation pane..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "HubMode" -ErrorAction SilentlyContinue +} + +# Hide Recycle Bin shortcut from desktop +Function HideRecycleBinFromDesktop { + Write-Output "Hiding Recycle Bin shortcut from desktop..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Name "{645FF040-5081-101B-9F08-00AA002F954E}" -Type DWord -Value 1 + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name "{645FF040-5081-101B-9F08-00AA002F954E}" -Type DWord -Value 1 +} + +# Show Recycle Bin shortcut on desktop +Function ShowRecycleBinOnDesktop { + Write-Output "Showing Recycle Bin shortcut on desktop..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Name "{645FF040-5081-101B-9F08-00AA002F954E}" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name "{645FF040-5081-101B-9F08-00AA002F954E}" -ErrorAction SilentlyContinue +} + +# Show This PC shortcut on desktop +Function ShowThisPCOnDesktop { + Write-Output "Showing This PC shortcut on desktop..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Name "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" -Type DWord -Value 0 + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" -Type DWord -Value 0 +} + +# Hide This PC shortcut from desktop +Function HideThisPCFromDesktop { + Write-Output "Hiding This PC shortcut from desktop..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Name "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name "{20D04FE0-3AEA-1069-A2D8-08002B30309D}" -ErrorAction SilentlyContinue +} + +# Show User Folder shortcut on desktop +Function ShowUserFolderOnDesktop { + Write-Output "Showing User Folder shortcut on desktop..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Name "{59031a47-3f72-44a7-89c5-5595fe6b30ee}" -Type DWord -Value 0 + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name "{59031a47-3f72-44a7-89c5-5595fe6b30ee}" -Type DWord -Value 0 +} + +# Hide User Folder shortcut from desktop +Function HideUserFolderFromDesktop { + Write-Output "Hiding User Folder shortcut from desktop..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Name "{59031a47-3f72-44a7-89c5-5595fe6b30ee}" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name "{59031a47-3f72-44a7-89c5-5595fe6b30ee}" -ErrorAction SilentlyContinue +} + +# Show Control panel shortcut on desktop +Function ShowControlPanelOnDesktop { + Write-Output "Showing Control panel shortcut on desktop..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Name "{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}" -Type DWord -Value 0 + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name "{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}" -Type DWord -Value 0 +} + +# Hide Control panel shortcut from desktop +Function HideControlPanelFromDesktop { + Write-Output "Hiding Control panel shortcut from desktop..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Name "{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name "{5399E694-6CE5-4D6C-8FCE-1D8870FDCBA0}" -ErrorAction SilentlyContinue +} + +# Show Network shortcut on desktop +Function ShowNetworkOnDesktop { + Write-Output "Showing Network shortcut on desktop..." + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" )) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Name "{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}" -Type DWord -Value 0 + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" )) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name "{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}" -Type DWord -Value 0 +} + +# Hide Network shortcut from desktop +Function HideNetworkFromDesktop { + Write-Output "Hiding Network shortcut from desktop..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\ClassicStartMenu" -Name "{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\HideDesktopIcons\NewStartPanel" -Name "{F02C1A0D-BE21-4350-88B0-7367FC96EF3C}" -ErrorAction SilentlyContinue +} + +# Show Windows build number and Windows edition (Home/Pro/Enterprise) from bottom right of desktop +Function ShowBuildNumberOnDesktop { + Write-Output "Showing Windows build number on desktop..." + Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "PaintDesktopVersion" -Type DWord -Value 1 +} + +# Remove Windows build number and Windows edition (Home/Pro/Enterprise) from bottom right of desktop +Function HideBuildNumberFromDesktop { + Write-Output "Hiding Windows build number from desktop..." + Set-ItemProperty -Path "HKCU:\Control Panel\Desktop" -Name "PaintDesktopVersion" -Type DWord -Value 0 +} + +# Hide Desktop icon from This PC - The icon remains in personal folders and open/save dialogs +Function HideDesktopFromThisPC { + Write-Output "Hiding Desktop icon from This PC..." + Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}" -Recurse -ErrorAction SilentlyContinue +} + +# Show Desktop icon in This PC +Function ShowDesktopInThisPC { + Write-Output "Showing Desktop icon in This PC..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}" | Out-Null + } +} + +# Hide Desktop icon from Explorer namespace - Hides the icon also from personal folders and open/save dialogs +Function HideDesktopFromExplorer { + Write-Output "Hiding Desktop icon from Explorer namespace..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Hide" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Hide" +} + +# Show Desktop icon in Explorer namespace +Function ShowDesktopInExplorer { + Write-Output "Showing Desktop icon in Explorer namespace..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Show" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{B4BFCC3A-DB2C-424C-B029-7FE99A87C641}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Show" +} + +# Hide Documents icon from This PC - The icon remains in personal folders and open/save dialogs +Function HideDocumentsFromThisPC { + Write-Output "Hiding Documents icon from This PC..." + Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{d3162b92-9365-467a-956b-92703aca08af}" -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A8CDFF1C-4878-43be-B5FD-F8091C1C60D0}" -Recurse -ErrorAction SilentlyContinue +} + +# Show Documents icon in This PC +Function ShowDocumentsInThisPC { + Write-Output "Showing Documents icon in This PC..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{d3162b92-9365-467a-956b-92703aca08af}")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{d3162b92-9365-467a-956b-92703aca08af}" | Out-Null + } + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A8CDFF1C-4878-43be-B5FD-F8091C1C60D0}")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A8CDFF1C-4878-43be-B5FD-F8091C1C60D0}" | Out-Null + } +} + +# Hide Documents icon from Explorer namespace - Hides the icon also from personal folders and open/save dialogs +Function HideDocumentsFromExplorer { + Write-Output "Hiding Documents icon from Explorer namespace..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{f42ee2d3-909f-4907-8871-4c22fc0bf756}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Hide" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{f42ee2d3-909f-4907-8871-4c22fc0bf756}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Hide" +} + +# Show Documents icon in Explorer namespace +Function ShowDocumentsInExplorer { + Write-Output "Showing Documents icon in Explorer namespace..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{f42ee2d3-909f-4907-8871-4c22fc0bf756}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Show" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{f42ee2d3-909f-4907-8871-4c22fc0bf756}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Show" +} + +# Hide Downloads icon from This PC - The icon remains in personal folders and open/save dialogs +Function HideDownloadsFromThisPC { + Write-Output "Hiding Downloads icon from This PC..." + Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{088e3905-0323-4b02-9826-5d99428e115f}" -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{374DE290-123F-4565-9164-39C4925E467B}" -Recurse -ErrorAction SilentlyContinue +} + +# Show Downloads icon in This PC +Function ShowDownloadsInThisPC { + Write-Output "Showing Downloads icon in This PC..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{088e3905-0323-4b02-9826-5d99428e115f}")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{088e3905-0323-4b02-9826-5d99428e115f}" | Out-Null + } + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{374DE290-123F-4565-9164-39C4925E467B}")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{374DE290-123F-4565-9164-39C4925E467B}" | Out-Null + } +} + +# Hide Downloads icon from Explorer namespace - Hides the icon also from personal folders and open/save dialogs +Function HideDownloadsFromExplorer { + Write-Output "Hiding Downloads icon from Explorer namespace..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{7d83ee9b-2244-4e70-b1f5-5393042af1e4}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Hide" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{7d83ee9b-2244-4e70-b1f5-5393042af1e4}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Hide" +} + +# Show Downloads icon in Explorer namespace +Function ShowDownloadsInExplorer { + Write-Output "Showing Downloads icon in Explorer namespace..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{7d83ee9b-2244-4e70-b1f5-5393042af1e4}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Show" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{7d83ee9b-2244-4e70-b1f5-5393042af1e4}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Show" +} + +# Hide Music icon from This PC - The icon remains in personal folders and open/save dialogs +Function HideMusicFromThisPC { + Write-Output "Hiding Music icon from This PC..." + Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3dfdf296-dbec-4fb4-81d1-6a3438bcf4de}" -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{1CF1260C-4DD0-4ebb-811F-33C572699FDE}" -Recurse -ErrorAction SilentlyContinue +} + +# Show Music icon in This PC +Function ShowMusicInThisPC { + Write-Output "Showing Music icon in This PC..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3dfdf296-dbec-4fb4-81d1-6a3438bcf4de}")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3dfdf296-dbec-4fb4-81d1-6a3438bcf4de}" | Out-Null + } + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{1CF1260C-4DD0-4ebb-811F-33C572699FDE}")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{1CF1260C-4DD0-4ebb-811F-33C572699FDE}" | Out-Null + } +} + +# Hide Music icon from Explorer namespace - Hides the icon also from personal folders and open/save dialogs +Function HideMusicFromExplorer { + Write-Output "Hiding Music icon from Explorer namespace..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{a0c69a99-21c8-4671-8703-7934162fcf1d}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Hide" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{a0c69a99-21c8-4671-8703-7934162fcf1d}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Hide" +} + +# Show Music icon in Explorer namespace +Function ShowMusicInExplorer { + Write-Output "Showing Music icon in Explorer namespace..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{a0c69a99-21c8-4671-8703-7934162fcf1d}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Show" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{a0c69a99-21c8-4671-8703-7934162fcf1d}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Show" +} + +# Hide Pictures icon from This PC - The icon remains in personal folders and open/save dialogs +Function HidePicturesFromThisPC { + Write-Output "Hiding Pictures icon from This PC..." + Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{24ad3ad4-a569-4530-98e1-ab02f9417aa8}" -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3ADD1653-EB32-4cb0-BBD7-DFA0ABB5ACCA}" -Recurse -ErrorAction SilentlyContinue +} + +# Show Pictures icon in This PC +Function ShowPicturesInThisPC { + Write-Output "Showing Pictures icon in This PC..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{24ad3ad4-a569-4530-98e1-ab02f9417aa8}")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{24ad3ad4-a569-4530-98e1-ab02f9417aa8}" | Out-Null + } + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3ADD1653-EB32-4cb0-BBD7-DFA0ABB5ACCA}")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{3ADD1653-EB32-4cb0-BBD7-DFA0ABB5ACCA}" | Out-Null + } +} + +# Hide Pictures icon from Explorer namespace - Hides the icon also from personal folders and open/save dialogs +Function HidePicturesFromExplorer { + Write-Output "Hiding Pictures icon from Explorer namespace..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{0ddd015d-b06c-45d5-8c4c-f59713854639}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Hide" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{0ddd015d-b06c-45d5-8c4c-f59713854639}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Hide" +} + +# Show Pictures icon in Explorer namespace +Function ShowPicturesInExplorer { + Write-Output "Showing Pictures icon in Explorer namespace..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{0ddd015d-b06c-45d5-8c4c-f59713854639}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Show" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{0ddd015d-b06c-45d5-8c4c-f59713854639}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Show" +} + +# Hide Videos icon from This PC - The icon remains in personal folders and open/save dialogs +Function HideVideosFromThisPC { + Write-Output "Hiding Videos icon from This PC..." + Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}" -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A0953C92-50DC-43bf-BE83-3742FED03C9C}" -Recurse -ErrorAction SilentlyContinue +} + +# Show Videos icon in This PC +Function ShowVideosInThisPC { + Write-Output "Showing Videos icon in This PC..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}" | Out-Null + } + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A0953C92-50DC-43bf-BE83-3742FED03C9C}")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{A0953C92-50DC-43bf-BE83-3742FED03C9C}" | Out-Null + } +} + +# Hide Videos icon from Explorer namespace - Hides the icon also from personal folders and open/save dialogs +Function HideVideosFromExplorer { + Write-Output "Hiding Videos icon from Explorer namespace..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{35286a68-3c57-41a1-bbb1-0eae73d76c95}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Hide" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{35286a68-3c57-41a1-bbb1-0eae73d76c95}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Hide" +} + +# Show Videos icon in Explorer namespace +Function ShowVideosInExplorer { + Write-Output "Showing Videos icon in Explorer namespace..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{35286a68-3c57-41a1-bbb1-0eae73d76c95}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Show" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{35286a68-3c57-41a1-bbb1-0eae73d76c95}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Show" +} + +# Hide 3D Objects icon from This PC - The icon remains in personal folders and open/save dialogs +Function Hide3DObjectsFromThisPC { + Write-Output "Hiding 3D Objects icon from This PC..." + Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" -Recurse -ErrorAction SilentlyContinue +} + +# Show 3D Objects icon in This PC +Function Show3DObjectsInThisPC { + Write-Output "Showing 3D Objects icon in This PC..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" | Out-Null + } +} + +# Hide 3D Objects icon from Explorer namespace - Hides the icon also from personal folders and open/save dialogs +Function Hide3DObjectsFromExplorer { + Write-Output "Hiding 3D Objects icon from Explorer namespace..." + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Hide" + If (!(Test-Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag")) { + New-Item -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag" -Name "ThisPCPolicy" -Type String -Value "Hide" +} + +# Show 3D Objects icon in Explorer namespace +Function Show3DObjectsInExplorer { + Write-Output "Showing 3D Objects icon in Explorer namespace..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag" -Name "ThisPCPolicy" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Explorer\FolderDescriptions\{31C0DD25-9439-4F12-BF41-7FF4EDA38722}\PropertyBag" -Name "ThisPCPolicy" -ErrorAction SilentlyContinue +} + +# Hide 'Include in library' context menu item +Function HideIncludeInLibraryMenu { + Write-Output "Hiding 'Include in library' context menu item..." + If (!(Test-Path "HKCR:")) { + New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null + } + Remove-Item -Path "HKCR:\Folder\ShellEx\ContextMenuHandlers\Library Location" -ErrorAction SilentlyContinue +} + +# Show 'Include in library' context menu item +Function ShowIncludeInLibraryMenu { + Write-Output "Showing 'Include in library' context menu item..." + If (!(Test-Path "HKCR:")) { + New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null + } + New-Item -Path "HKCR:\Folder\ShellEx\ContextMenuHandlers\Library Location" -ErrorAction SilentlyContinue | Out-Null + Set-ItemProperty -Path "HKCR:\Folder\ShellEx\ContextMenuHandlers\Library Location" -Name "(Default)" -Type String -Value "{3dad6c5d-2167-4cae-9914-f99e41c12cfa}" +} + +# Hide 'Give access to' (until 1703 'Share With') context menu item. +Function HideGiveAccessToMenu { + Write-Output "Hiding 'Give access to' context menu item..." + If (!(Test-Path "HKCR:")) { + New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null + } + Remove-Item -LiteralPath "HKCR:\*\shellex\ContextMenuHandlers\Sharing" -ErrorAction SilentlyContinue + Remove-Item -Path "HKCR:\Directory\Background\shellex\ContextMenuHandlers\Sharing" -ErrorAction SilentlyContinue + Remove-Item -Path "HKCR:\Directory\shellex\ContextMenuHandlers\Sharing" -ErrorAction SilentlyContinue + Remove-Item -Path "HKCR:\Drive\shellex\ContextMenuHandlers\Sharing" -ErrorAction SilentlyContinue + +} + +# Show 'Give access to' (until 1703 'Share With') context menu item. +Function ShowGiveAccessToMenu { + Write-Output "Showing 'Give access to' context menu item..." + If (!(Test-Path "HKCR:")) { + New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null + } + New-Item -Path "HKCR:\*\shellex\ContextMenuHandlers\Sharing" -ErrorAction SilentlyContinue | Out-Null + Set-ItemProperty -LiteralPath "HKCR:\*\shellex\ContextMenuHandlers\Sharing" -Name "(Default)" -Type String -Value "{f81e9010-6ea4-11ce-a7ff-00aa003ca9f6}" + New-Item -Path "HKCR:\Directory\Background\shellex\ContextMenuHandlers\Sharing" -ErrorAction SilentlyContinue | Out-Null + Set-ItemProperty -Path "HKCR:\Directory\Background\shellex\ContextMenuHandlers\Sharing" -Name "(Default)" -Type String -Value "{f81e9010-6ea4-11ce-a7ff-00aa003ca9f6}" + New-Item -Path "HKCR:\Directory\shellex\ContextMenuHandlers\Sharing" -ErrorAction SilentlyContinue | Out-Null + Set-ItemProperty -Path "HKCR:\Directory\shellex\ContextMenuHandlers\Sharing" -Name "(Default)" -Type String -Value "{f81e9010-6ea4-11ce-a7ff-00aa003ca9f6}" + New-Item -Path "HKCR:\Drive\shellex\ContextMenuHandlers\Sharing" -ErrorAction SilentlyContinue | Out-Null + Set-ItemProperty -Path "HKCR:\Drive\shellex\ContextMenuHandlers\Sharing" -Name "(Default)" -Type String -Value "{f81e9010-6ea4-11ce-a7ff-00aa003ca9f6}" +} + +# Hide 'Share' context menu item. Applicable since 1709 +Function HideShareMenu { + Write-Output "Hiding 'Share' context menu item..." + If (!(Test-Path "HKCR:")) { + New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null + } + Remove-Item -LiteralPath "HKCR:\*\shellex\ContextMenuHandlers\ModernSharing" -ErrorAction SilentlyContinue +} + +# Show 'Share' context menu item. Applicable since 1709 +Function ShowShareMenu { + Write-Output "Showing 'Share' context menu item..." + If (!(Test-Path "HKCR:")) { + New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null + } + New-Item -Path "HKCR:\*\shellex\ContextMenuHandlers\ModernSharing" -ErrorAction SilentlyContinue | Out-Null + Set-ItemProperty -LiteralPath "HKCR:\*\shellex\ContextMenuHandlers\ModernSharing" -Name "(Default)" -Type String -Value "{e2bf9676-5f8f-435c-97eb-11607a5bedf7}" +} + +# Disable thumbnails, show only file extension icons +Function DisableThumbnails { + Write-Output "Disabling thumbnails..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "IconsOnly" -Type DWord -Value 1 +} + +# Enable thumbnails +Function EnableThumbnails { + Write-Output "Enabling thumbnails..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "IconsOnly" -Type DWord -Value 0 +} + +# Disable creation of thumbnail cache files +Function DisableThumbnailCache { + Write-Output "Disabling creation of thumbnail cache files..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "DisableThumbnailCache" -Type DWord -Value 1 +} + +# Enable creation of thumbnail cache files +Function EnableThumbnailCache { + Write-Output "Enabling creation of thumbnail cache files..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "DisableThumbnailCache" -ErrorAction SilentlyContinue +} + +# Disable creation of Thumbs.db thumbnail cache files on network folders +Function DisableThumbsDBOnNetwork { + Write-Output "Disabling creation of Thumbs.db on network folders..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "DisableThumbsDBOnNetworkFolders" -Type DWord -Value 1 +} + +# Enable creation of Thumbs.db thumbnail cache files on network folders +Function EnableThumbsDBOnNetwork { + Write-Output "Enabling creation of Thumbs.db on network folders..." + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "DisableThumbsDBOnNetworkFolders" -ErrorAction SilentlyContinue +} + +########## +#endregion Explorer UI Tweaks +########## + + + +########## +#region Application Tweaks +########## + +# Disable OneDrive +Function DisableOneDrive { + Write-Output "Disabling OneDrive..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Name "DisableFileSyncNGSC" -Type DWord -Value 1 +} + +# Enable OneDrive +Function EnableOneDrive { + Write-Output "Enabling OneDrive..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Name "DisableFileSyncNGSC" -ErrorAction SilentlyContinue +} + +# Uninstall OneDrive - Not applicable to Server +Function UninstallOneDrive { + Write-Output "Uninstalling OneDrive..." + Stop-Process -Name "OneDrive" -Force -ErrorAction SilentlyContinue + Start-Sleep -s 2 + $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe" + If (!(Test-Path $onedrive)) { + $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe" + } + Start-Process $onedrive "/uninstall" -NoNewWindow -Wait + Start-Sleep -s 2 + Stop-Process -Name "explorer" -Force -ErrorAction SilentlyContinue + Start-Sleep -s 2 + If ((Get-ChildItem -Path "$env:USERPROFILE\OneDrive" -ErrorAction SilentlyContinue | Measure-Object).Count -eq 0) { + Remove-Item -Path "$env:USERPROFILE\OneDrive" -Force -Recurse -ErrorAction SilentlyContinue + } + Remove-Item -Path "$env:LOCALAPPDATA\Microsoft\OneDrive" -Force -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path "$env:PROGRAMDATA\Microsoft OneDrive" -Force -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path "$env:SYSTEMDRIVE\OneDriveTemp" -Force -Recurse -ErrorAction SilentlyContinue + If (!(Test-Path "HKCR:")) { + New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null + } + Remove-Item -Path "HKCR:\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path "HKCR:\Wow6432Node\CLSID\{018D5C66-4533-4307-9B53-224DE2ED1FE6}" -Recurse -ErrorAction SilentlyContinue +} + +# Install OneDrive - Not applicable to Server +Function InstallOneDrive { + Write-Output "Installing OneDrive..." + $onedrive = "$env:SYSTEMROOT\SysWOW64\OneDriveSetup.exe" + If (!(Test-Path $onedrive)) { + $onedrive = "$env:SYSTEMROOT\System32\OneDriveSetup.exe" + } + Start-Process $onedrive -NoNewWindow +} + +# Uninstall default Microsoft applications +Function UninstallMsftBloat { + Write-Output "Uninstalling default Microsoft applications..." + Get-AppxPackage "Microsoft.3DBuilder" | Remove-AppxPackage + Get-AppxPackage "Microsoft.AppConnector" | Remove-AppxPackage + Get-AppxPackage "Microsoft.BingFinance" | Remove-AppxPackage + Get-AppxPackage "Microsoft.BingFoodAndDrink" | Remove-AppxPackage + Get-AppxPackage "Microsoft.BingHealthAndFitness" | Remove-AppxPackage + Get-AppxPackage "Microsoft.BingMaps" | Remove-AppxPackage + Get-AppxPackage "Microsoft.BingNews" | Remove-AppxPackage + Get-AppxPackage "Microsoft.BingSports" | Remove-AppxPackage + Get-AppxPackage "Microsoft.BingTranslator" | Remove-AppxPackage + Get-AppxPackage "Microsoft.BingTravel" | Remove-AppxPackage + Get-AppxPackage "Microsoft.BingWeather" | Remove-AppxPackage + Get-AppxPackage "Microsoft.CommsPhone" | Remove-AppxPackage + Get-AppxPackage "Microsoft.ConnectivityStore" | Remove-AppxPackage + Get-AppxPackage "Microsoft.FreshPaint" | Remove-AppxPackage + Get-AppxPackage "Microsoft.GetHelp" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Getstarted" | Remove-AppxPackage + Get-AppxPackage "Microsoft.HelpAndTips" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Media.PlayReadyClient.2" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Messaging" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Microsoft3DViewer" | Remove-AppxPackage + Get-AppxPackage "Microsoft.MicrosoftOfficeHub" | Remove-AppxPackage + Get-AppxPackage "Microsoft.MicrosoftPowerBIForWindows" | Remove-AppxPackage + Get-AppxPackage "Microsoft.MicrosoftSolitaireCollection" | Remove-AppxPackage + Get-AppxPackage "Microsoft.MicrosoftStickyNotes" | Remove-AppxPackage + Get-AppxPackage "Microsoft.MinecraftUWP" | Remove-AppxPackage + Get-AppxPackage "Microsoft.MixedReality.Portal" | Remove-AppxPackage + Get-AppxPackage "Microsoft.MoCamera" | Remove-AppxPackage + Get-AppxPackage "Microsoft.MSPaint" | Remove-AppxPackage + Get-AppxPackage "Microsoft.NetworkSpeedTest" | Remove-AppxPackage + Get-AppxPackage "Microsoft.OfficeLens" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Office.OneNote" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Office.Sway" | Remove-AppxPackage + Get-AppxPackage "Microsoft.OneConnect" | Remove-AppxPackage + Get-AppxPackage "Microsoft.People" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Print3D" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Reader" | Remove-AppxPackage + Get-AppxPackage "Microsoft.RemoteDesktop" | Remove-AppxPackage + Get-AppxPackage "Microsoft.SkypeApp" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Todos" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Wallet" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WebMediaExtensions" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Whiteboard" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsAlarms" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsCamera" | Remove-AppxPackage + Get-AppxPackage "microsoft.windowscommunicationsapps" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsFeedbackHub" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsMaps" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsPhone" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Windows.Photos" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsReadingList" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsScan" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsSoundRecorder" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WinJS.1.0" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WinJS.2.0" | Remove-AppxPackage + Get-AppxPackage "Microsoft.YourPhone" | Remove-AppxPackage + Get-AppxPackage "Microsoft.ZuneMusic" | Remove-AppxPackage + Get-AppxPackage "Microsoft.ZuneVideo" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Advertising.Xaml" | Remove-AppxPackage # Dependency for microsoft.windowscommunicationsapps, Microsoft.BingWeather +} + +# Install default Microsoft applications +Function InstallMsftBloat { + Write-Output "Installing default Microsoft applications..." + Get-AppxPackage -AllUsers "Microsoft.3DBuilder" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Advertising.Xaml" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} # Dependency for microsoft.windowscommunicationsapps, Microsoft.BingWeather + Get-AppxPackage -AllUsers "Microsoft.AppConnector" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.BingFinance" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.BingFoodAndDrink" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.BingHealthAndFitness" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.BingMaps" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.BingNews" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.BingSports" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.BingTranslator" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.BingTravel" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.BingWeather" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.CommsPhone" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.ConnectivityStore" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.FreshPaint" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.GetHelp" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Getstarted" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.HelpAndTips" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Media.PlayReadyClient.2" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Messaging" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Microsoft3DViewer" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.MicrosoftOfficeHub" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.MicrosoftPowerBIForWindows" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.MicrosoftSolitaireCollection" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.MicrosoftStickyNotes" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.MinecraftUWP" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.MixedReality.Portal" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.MoCamera" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.MSPaint" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.NetworkSpeedTest" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.OfficeLens" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Office.OneNote" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Office.Sway" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.OneConnect" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.People" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Print3D" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Reader" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.RemoteDesktop" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.SkypeApp" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Todos" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Wallet" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.WebMediaExtensions" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Whiteboard" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.WindowsAlarms" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.WindowsCamera" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.windowscommunicationsapps" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.WindowsFeedbackHub" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.WindowsMaps" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.WindowsPhone" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Windows.Photos" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.WindowsReadingList" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.WindowsScan" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.WindowsSoundRecorder" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.WinJS.1.0" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.WinJS.2.0" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.YourPhone" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.ZuneMusic" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.ZuneVideo" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} +} +# In case you have removed them for good, you can try to restore the files using installation medium as follows +# New-Item C:\Mnt -Type Directory | Out-Null +# dism /Mount-Image /ImageFile:D:\sources\install.wim /index:1 /ReadOnly /MountDir:C:\Mnt +# robocopy /S /SEC /R:0 "C:\Mnt\Program Files\WindowsApps" "C:\Program Files\WindowsApps" +# dism /Unmount-Image /Discard /MountDir:C:\Mnt +# Remove-Item -Path C:\Mnt -Recurse + +# Uninstall default third party applications +function UninstallThirdPartyBloat { + Write-Output "Uninstalling default third party applications..." + Get-AppxPackage "2414FC7A.Viber" | Remove-AppxPackage + Get-AppxPackage "41038Axilesoft.ACGMediaPlayer" | Remove-AppxPackage + Get-AppxPackage "46928bounde.EclipseManager" | Remove-AppxPackage + Get-AppxPackage "4DF9E0F8.Netflix" | Remove-AppxPackage + Get-AppxPackage "64885BlueEdge.OneCalendar" | Remove-AppxPackage + Get-AppxPackage "7EE7776C.LinkedInforWindows" | Remove-AppxPackage + Get-AppxPackage "828B5831.HiddenCityMysteryofShadows" | Remove-AppxPackage + Get-AppxPackage "89006A2E.AutodeskSketchBook" | Remove-AppxPackage + Get-AppxPackage "9E2F88E3.Twitter" | Remove-AppxPackage + Get-AppxPackage "A278AB0D.DisneyMagicKingdoms" | Remove-AppxPackage + Get-AppxPackage "A278AB0D.DragonManiaLegends" | Remove-AppxPackage + Get-AppxPackage "A278AB0D.MarchofEmpires" | Remove-AppxPackage + Get-AppxPackage "ActiproSoftwareLLC.562882FEEB491" | Remove-AppxPackage + Get-AppxPackage "AD2F1837.GettingStartedwithWindows8" | Remove-AppxPackage + Get-AppxPackage "AD2F1837.HPJumpStart" | Remove-AppxPackage + Get-AppxPackage "AD2F1837.HPRegistration" | Remove-AppxPackage + Get-AppxPackage "AdobeSystemsIncorporated.AdobePhotoshopExpress" | Remove-AppxPackage + Get-AppxPackage "Amazon.com.Amazon" | Remove-AppxPackage + Get-AppxPackage "C27EB4BA.DropboxOEM" | Remove-AppxPackage + Get-AppxPackage "CAF9E577.Plex" | Remove-AppxPackage + Get-AppxPackage "CyberLinkCorp.hs.PowerMediaPlayer14forHPConsumerPC" | Remove-AppxPackage + Get-AppxPackage "D52A8D61.FarmVille2CountryEscape" | Remove-AppxPackage + Get-AppxPackage "D5EA27B7.Duolingo-LearnLanguagesforFree" | Remove-AppxPackage + Get-AppxPackage "DB6EA5DB.CyberLinkMediaSuiteEssentials" | Remove-AppxPackage + Get-AppxPackage "DolbyLaboratories.DolbyAccess" | Remove-AppxPackage + Get-AppxPackage "Drawboard.DrawboardPDF" | Remove-AppxPackage + Get-AppxPackage "E046963F.LenovoCompanion" | Remove-AppxPackage + Get-AppxPackage "Facebook.Facebook" | Remove-AppxPackage + Get-AppxPackage "Fitbit.FitbitCoach" | Remove-AppxPackage + Get-AppxPackage "flaregamesGmbH.RoyalRevolt2" | Remove-AppxPackage + Get-AppxPackage "GAMELOFTSA.Asphalt8Airborne" | Remove-AppxPackage + Get-AppxPackage "KeeperSecurityInc.Keeper" | Remove-AppxPackage + Get-AppxPackage "king.com.BubbleWitch3Saga" | Remove-AppxPackage + Get-AppxPackage "king.com.CandyCrushFriends" | Remove-AppxPackage + Get-AppxPackage "king.com.CandyCrushSaga" | Remove-AppxPackage + Get-AppxPackage "king.com.CandyCrushSodaSaga" | Remove-AppxPackage + Get-AppxPackage "LenovoCorporation.LenovoID" | Remove-AppxPackage + Get-AppxPackage "LenovoCorporation.LenovoSettings" | Remove-AppxPackage + Get-AppxPackage "Nordcurrent.CookingFever" | Remove-AppxPackage + Get-AppxPackage "PandoraMediaInc.29680B314EFC2" | Remove-AppxPackage + Get-AppxPackage "PricelinePartnerNetwork.Booking.comBigsavingsonhot" | Remove-AppxPackage + Get-AppxPackage "SpotifyAB.SpotifyMusic" | Remove-AppxPackage + Get-AppxPackage "ThumbmunkeysLtd.PhototasticCollage" | Remove-AppxPackage + Get-AppxPackage "WinZipComputing.WinZipUniversal" | Remove-AppxPackage + Get-AppxPackage "XINGAG.XING" | Remove-AppxPackage +} + +# Install default third party applications +Function InstallThirdPartyBloat { + Write-Output "Installing default third party applications..." + Get-AppxPackage -AllUsers "2414FC7A.Viber" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "41038Axilesoft.ACGMediaPlayer" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "46928bounde.EclipseManager" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "4DF9E0F8.Netflix" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "64885BlueEdge.OneCalendar" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "7EE7776C.LinkedInforWindows" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "828B5831.HiddenCityMysteryofShadows" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "89006A2E.AutodeskSketchBook" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "9E2F88E3.Twitter" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "A278AB0D.DisneyMagicKingdoms" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "A278AB0D.DragonManiaLegends" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "A278AB0D.MarchofEmpires" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "ActiproSoftwareLLC.562882FEEB491" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "AD2F1837.GettingStartedwithWindows8" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "AD2F1837.HPJumpStart" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "AD2F1837.HPRegistration" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "AdobeSystemsIncorporated.AdobePhotoshopExpress" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Amazon.com.Amazon" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "C27EB4BA.DropboxOEM" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "CAF9E577.Plex" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "CyberLinkCorp.hs.PowerMediaPlayer14forHPConsumerPC" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "D52A8D61.FarmVille2CountryEscape" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "D5EA27B7.Duolingo-LearnLanguagesforFree" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "DB6EA5DB.CyberLinkMediaSuiteEssentials" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "DolbyLaboratories.DolbyAccess" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Drawboard.DrawboardPDF" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "E046963F.LenovoCompanion" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Facebook.Facebook" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Fitbit.FitbitCoach" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "flaregamesGmbH.RoyalRevolt2" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "GAMELOFTSA.Asphalt8Airborne" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "KeeperSecurityInc.Keeper" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "king.com.BubbleWitch3Saga" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "king.com.CandyCrushFriends" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "king.com.CandyCrushSaga" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "king.com.CandyCrushSodaSaga" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "LenovoCorporation.LenovoID" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "LenovoCorporation.LenovoSettings" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Nordcurrent.CookingFever" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "PandoraMediaInc.29680B314EFC2" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "PricelinePartnerNetwork.Booking.comBigsavingsonhot" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "SpotifyAB.SpotifyMusic" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "ThumbmunkeysLtd.PhototasticCollage" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "WinZipComputing.WinZipUniversal" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "XINGAG.XING" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} +} + +# Uninstall Windows Store +Function UninstallWindowsStore { + Write-Output "Uninstalling Windows Store..." + Get-AppxPackage "Microsoft.DesktopAppInstaller" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Services.Store.Engagement" | Remove-AppxPackage + Get-AppxPackage "Microsoft.StorePurchaseApp" | Remove-AppxPackage + Get-AppxPackage "Microsoft.WindowsStore" | Remove-AppxPackage +} + +# Install Windows Store +Function InstallWindowsStore { + Write-Output "Installing Windows Store..." + Get-AppxPackage -AllUsers "Microsoft.DesktopAppInstaller" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Services.Store.Engagement" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.StorePurchaseApp" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.WindowsStore" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} +} + +# Disable Xbox features - Not applicable to Server +Function DisableXboxFeatures { + Write-Output "Disabling Xbox features..." + Get-AppxPackage "Microsoft.XboxApp" | Remove-AppxPackage + Get-AppxPackage "Microsoft.XboxIdentityProvider" | Remove-AppxPackage -ErrorAction SilentlyContinue + Get-AppxPackage "Microsoft.XboxSpeechToTextOverlay" | Remove-AppxPackage + Get-AppxPackage "Microsoft.XboxGameOverlay" | Remove-AppxPackage + Get-AppxPackage "Microsoft.XboxGamingOverlay" | Remove-AppxPackage + Get-AppxPackage "Microsoft.Xbox.TCUI" | Remove-AppxPackage + Set-ItemProperty -Path "HKCU:\Software\Microsoft\GameBar" -Name "AutoGameModeEnabled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_Enabled" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR" | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR" -Name "AllowGameDVR" -Type DWord -Value 0 +} + +# Enable Xbox features - Not applicable to Server +Function EnableXboxFeatures { + Write-Output "Enabling Xbox features..." + Get-AppxPackage -AllUsers "Microsoft.XboxApp" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.XboxIdentityProvider" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.XboxSpeechToTextOverlay" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.XboxGameOverlay" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.XboxGamingOverlay" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Get-AppxPackage -AllUsers "Microsoft.Xbox.TCUI" | ForEach-Object {Add-AppxPackage -DisableDevelopmentMode -Register "$($_.InstallLocation)\AppXManifest.xml"} + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\GameBar" -Name "AutoGameModeEnabled" -ErrorAction SilentlyContinue + Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_Enabled" -Type DWord -Value 1 + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\GameDVR" -Name "AllowGameDVR" -ErrorAction SilentlyContinue +} + +# Disable Fullscreen optimizations +Function DisableFullscreenOptims { + Write-Output "Disabling Fullscreen optimizations..." + Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_DXGIHonorFSEWindowsCompatible" -Type DWord -Value 1 + Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_FSEBehavior" -Type DWord -Value 2 + Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_FSEBehaviorMode" -Type DWord -Value 2 + Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_HonorUserFSEBehaviorMode" -Type DWord -Value 1 +} + +# Enable Fullscreen optimizations +Function EnableFullscreenOptims { + Write-Output "Enabling Fullscreen optimizations..." + Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_DXGIHonorFSEWindowsCompatible" -Type DWord -Value 0 + Remove-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_FSEBehavior" -ErrorAction SilentlyContinue + Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_FSEBehaviorMode" -Type DWord -Value 0 + Set-ItemProperty -Path "HKCU:\System\GameConfigStore" -Name "GameDVR_HonorUserFSEBehaviorMode" -Type DWord -Value 0 +} + +# Disable built-in Adobe Flash in IE and Edge +Function DisableAdobeFlash { + Write-Output "Disabling built-in Adobe Flash in IE and Edge..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer" -Name "DisableFlashInIE" -Type DWord -Value 1 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\Addons")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\Addons" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\Addons" -Name "FlashPlayerEnabled" -Type DWord -Value 0 +} + +# Enable built-in Adobe Flash in IE and Edge +Function EnableAdobeFlash { + Write-Output "Enabling built-in Adobe Flash in IE and Edge..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer" -Name "DisableFlashInIE" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\Addons" -Name "FlashPlayerEnabled" -ErrorAction SilentlyContinue +} + +# Disable Edge preload after Windows startup - Applicable since Win10 1809 +Function DisableEdgePreload { + Write-Output "Disabling Edge preload..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\Main")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\Main" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\Main" -Name "AllowPrelaunch" -Type DWord -Value 0 + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\TabPreloader")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\TabPreloader" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\TabPreloader" -Name "AllowTabPreloading" -Type DWord -Value 0 +} + +# Enable Edge preload after Windows startup +Function EnableEdgePreload { + Write-Output "Enabling Edge preload..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\Main" -Name "AllowPrelaunch" -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\MicrosoftEdge\TabPreloader" -Name "AllowTabPreloading" -ErrorAction SilentlyContinue +} + +# Disable Edge desktop shortcut creation after certain Windows updates are applied +Function DisableEdgeShortcutCreation { + Write-Output "Disabling Edge shortcut creation..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "DisableEdgeDesktopShortcutCreation" -Type DWord -Value 1 +} + +# Enable Edge desktop shortcut creation after certain Windows updates are applied +Function EnableEdgeShortcutCreation { + Write-Output "Enabling Edge shortcut creation..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer" -Name "DisableEdgeDesktopShortcutCreation" -ErrorAction SilentlyContinue +} + +# Disable Internet Explorer first run wizard +Function DisableIEFirstRun { + Write-Output "Disabling Internet Explorer first run wizard..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer\Main")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer\Main" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer\Main" -Name "DisableFirstRunCustomize" -Type DWord -Value 1 +} + +# Enable Internet Explorer first run wizard +Function EnableIEFirstRun { + Write-Output "Disabling Internet Explorer first run wizard..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Internet Explorer\Main" -Name "DisableFirstRunCustomize" -ErrorAction SilentlyContinue +} + +# Disable "Hi!" First Logon Animation (it will be replaced by "Preparing Windows" message) +Function DisableFirstLogonAnimation { + Write-Output "Disabling First Logon Animation..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableFirstLogonAnimation" -Type DWord -Value 0 +} + +# Enable "Hi!" First Logon Animation +Function EnableFirstLogonAnimation { + Write-Output "Enabling First Logon Animation..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "EnableFirstLogonAnimation" -ErrorAction SilentlyContinue +} + +# Disable Windows Media Player's media sharing feature +Function DisableMediaSharing { + Write-Output "Disabling media sharing..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer" -Name "PreventLibrarySharing" -Type DWord -Value 1 +} + +# Enable Windows Media Player's media sharing feature +Function EnableMediaSharing { + Write-Output "Enabling media sharing..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsMediaPlayer" -Name "PreventLibrarySharing" -ErrorAction SilentlyContinue +} + +# Uninstall Windows Media Player +Function UninstallMediaPlayer { + Write-Output "Uninstalling Windows Media Player..." + Disable-WindowsOptionalFeature -Online -FeatureName "WindowsMediaPlayer" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Install Windows Media Player +Function InstallMediaPlayer { + Write-Output "Installing Windows Media Player..." + Enable-WindowsOptionalFeature -Online -FeatureName "WindowsMediaPlayer" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Uninstall Internet Explorer +Function UninstallInternetExplorer { + Write-Output "Uninstalling Internet Explorer..." + Disable-WindowsOptionalFeature -Online -FeatureName "Internet-Explorer-Optional-$env:PROCESSOR_ARCHITECTURE" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Install Internet Explorer +Function InstallInternetExplorer { + Write-Output "Installing Internet Explorer..." + Enable-WindowsOptionalFeature -Online -FeatureName "Internet-Explorer-Optional-$env:PROCESSOR_ARCHITECTURE" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Uninstall Work Folders Client - Not applicable to Server +Function UninstallWorkFolders { + Write-Output "Uninstalling Work Folders Client..." + Disable-WindowsOptionalFeature -Online -FeatureName "WorkFolders-Client" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Install Work Folders Client - Not applicable to Server +Function InstallWorkFolders { + Write-Output "Installing Work Folders Client..." + Enable-WindowsOptionalFeature -Online -FeatureName "WorkFolders-Client" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Uninstall PowerShell 2.0 Environment. +# PowerShell 2.0 is deprecated since September 2018. This doesn't affect PowerShell 5 or newer which is the default PowerShell environment. +# May affect Microsoft Diagnostic Tool and possibly other scripts. See https://blogs.msdn.microsoft.com/powershell/2017/08/24/windows-powershell-2-0-deprecation/ +Function UninstallPowerShellV2 { + Write-Output "Uninstalling PowerShell 2.0 Environment..." + If ((Get-CimInstance -Class "Win32_OperatingSystem").ProductType -eq 1) { + Disable-WindowsOptionalFeature -Online -FeatureName "MicrosoftWindowsPowerShellV2Root" -NoRestart -WarningAction SilentlyContinue | Out-Null + } Else { + Uninstall-WindowsFeature -Name "PowerShell-V2" -WarningAction SilentlyContinue | Out-Null + } +} + +# Install PowerShell 2.0 Environment +Function InstallPowerShellV2 { + Write-Output "Installing PowerShell 2.0 Environment..." + If ((Get-CimInstance -Class "Win32_OperatingSystem").ProductType -eq 1) { + Enable-WindowsOptionalFeature -Online -FeatureName "MicrosoftWindowsPowerShellV2Root" -NoRestart -WarningAction SilentlyContinue | Out-Null + } Else { + Install-WindowsFeature -Name "PowerShell-V2" -WarningAction SilentlyContinue | Out-Null + } +} + +# Install Linux Subsystem - Applicable since Win10 1607 and Server 1709 +# For automated Linux distribution installation, see https://docs.microsoft.com/en-us/windows/wsl/install-on-server +Function InstallLinuxSubsystem { + Write-Output "Installing Linux Subsystem..." + If ([System.Environment]::OSVersion.Version.Build -eq 14393) { + # 1607 needs developer mode to be enabled + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowDevelopmentWithoutDevLicense" -Type DWord -Value 1 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowAllTrustedApps" -Type DWord -Value 1 + } + Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Uninstall Linux Subsystem - Applicable since Win10 1607 and Server 1709 +Function UninstallLinuxSubsystem { + Write-Output "Uninstalling Linux Subsystem..." + If ([System.Environment]::OSVersion.Version.Build -eq 14393) { + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowDevelopmentWithoutDevLicense" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppModelUnlock" -Name "AllowAllTrustedApps" -Type DWord -Value 0 + } + Disable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Windows-Subsystem-Linux" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Install Hyper-V - Not applicable to Home +Function InstallHyperV { + Write-Output "Installing Hyper-V..." + If ((Get-CimInstance -Class "Win32_OperatingSystem").ProductType -eq 1) { + Enable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-All" -NoRestart -WarningAction SilentlyContinue | Out-Null + } Else { + Install-WindowsFeature -Name "Hyper-V" -IncludeManagementTools -WarningAction SilentlyContinue | Out-Null + } +} + +# Uninstall Hyper-V - Not applicable to Home +Function UninstallHyperV { + Write-Output "Uninstalling Hyper-V..." + If ((Get-CimInstance -Class "Win32_OperatingSystem").ProductType -eq 1) { + Disable-WindowsOptionalFeature -Online -FeatureName "Microsoft-Hyper-V-All" -NoRestart -WarningAction SilentlyContinue | Out-Null + } Else { + Uninstall-WindowsFeature -Name "Hyper-V" -IncludeManagementTools -WarningAction SilentlyContinue | Out-Null + } +} + +# Install .NET Framework 2.0, 3.0 and 3.5 runtimes - Requires internet connection +Function InstallNET23 { + Write-Output "Installing .NET Framework 2.0, 3.0 and 3.5 runtimes..." + If ((Get-CimInstance -Class "Win32_OperatingSystem").ProductType -eq 1) { + Enable-WindowsOptionalFeature -Online -FeatureName "NetFx3" -NoRestart -WarningAction SilentlyContinue | Out-Null + } Else { + Install-WindowsFeature -Name "NET-Framework-Core" -WarningAction SilentlyContinue | Out-Null + } +} + +# Uninstall .NET Framework 2.0, 3.0 and 3.5 runtimes +Function UninstallNET23 { + Write-Output "Uninstalling .NET Framework 2.0, 3.0 and 3.5 runtimes..." + If ((Get-CimInstance -Class "Win32_OperatingSystem").ProductType -eq 1) { + Disable-WindowsOptionalFeature -Online -FeatureName "NetFx3" -NoRestart -WarningAction SilentlyContinue | Out-Null + } Else { + Uninstall-WindowsFeature -Name "NET-Framework-Core" -WarningAction SilentlyContinue | Out-Null + } +} + +# Set Photo Viewer association for bmp, gif, jpg, png and tif +Function SetPhotoViewerAssociation { + Write-Output "Setting Photo Viewer association for bmp, gif, jpg, png and tif..." + If (!(Test-Path "HKCR:")) { + New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null + } + ForEach ($type in @("Paint.Picture", "giffile", "jpegfile", "pngfile")) { + New-Item -Path $("HKCR:\$type\shell\open") -Force | Out-Null + New-Item -Path $("HKCR:\$type\shell\open\command") | Out-Null + Set-ItemProperty -Path $("HKCR:\$type\shell\open") -Name "MuiVerb" -Type ExpandString -Value "@%ProgramFiles%\Windows Photo Viewer\photoviewer.dll,-3043" + 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" + } +} + +# Unset Photo Viewer association for bmp, gif, jpg, png and tif +Function UnsetPhotoViewerAssociation { + Write-Output "Unsetting Photo Viewer association for bmp, gif, jpg, png and tif..." + If (!(Test-Path "HKCR:")) { + New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null + } + Remove-Item -Path "HKCR:\Paint.Picture\shell\open" -Recurse -ErrorAction SilentlyContinue + Remove-ItemProperty -Path "HKCR:\giffile\shell\open" -Name "MuiVerb" -ErrorAction SilentlyContinue + Set-ItemProperty -Path "HKCR:\giffile\shell\open" -Name "CommandId" -Type String -Value "IE.File" + Set-ItemProperty -Path "HKCR:\giffile\shell\open\command" -Name "(Default)" -Type String -Value "`"$env:SystemDrive\Program Files\Internet Explorer\iexplore.exe`" %1" + Set-ItemProperty -Path "HKCR:\giffile\shell\open\command" -Name "DelegateExecute" -Type String -Value "{17FE9752-0B5A-4665-84CD-569794602F5C}" + Remove-Item -Path "HKCR:\jpegfile\shell\open" -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path "HKCR:\pngfile\shell\open" -Recurse -ErrorAction SilentlyContinue +} + +# Add Photo Viewer to 'Open with...' +Function AddPhotoViewerOpenWith { + Write-Output "Adding Photo Viewer to 'Open with...'" + If (!(Test-Path "HKCR:")) { + New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null + } + New-Item -Path "HKCR:\Applications\photoviewer.dll\shell\open\command" -Force | Out-Null + New-Item -Path "HKCR:\Applications\photoviewer.dll\shell\open\DropTarget" -Force | Out-Null + Set-ItemProperty -Path "HKCR:\Applications\photoviewer.dll\shell\open" -Name "MuiVerb" -Type String -Value "@photoviewer.dll,-3043" + 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" + Set-ItemProperty -Path "HKCR:\Applications\photoviewer.dll\shell\open\DropTarget" -Name "Clsid" -Type String -Value "{FFE2A43C-56B9-4bf5-9A79-CC6D4285608A}" +} + +# Remove Photo Viewer from 'Open with...' +Function RemovePhotoViewerOpenWith { + Write-Output "Removing Photo Viewer from 'Open with...'" + If (!(Test-Path "HKCR:")) { + New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null + } + Remove-Item -Path "HKCR:\Applications\photoviewer.dll\shell\open" -Recurse -ErrorAction SilentlyContinue +} + +# Uninstall Microsoft Print to PDF +Function UninstallPDFPrinter { + Write-Output "Uninstalling Microsoft Print to PDF..." + Disable-WindowsOptionalFeature -Online -FeatureName "Printing-PrintToPDFServices-Features" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Install Microsoft Print to PDF +Function InstallPDFPrinter { + Write-Output "Installing Microsoft Print to PDF..." + Enable-WindowsOptionalFeature -Online -FeatureName "Printing-PrintToPDFServices-Features" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Uninstall Microsoft XPS Document Writer +Function UninstallXPSPrinter { + Write-Output "Uninstalling Microsoft XPS Document Writer..." + Disable-WindowsOptionalFeature -Online -FeatureName "Printing-XPSServices-Features" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Install Microsoft XPS Document Writer +Function InstallXPSPrinter { + Write-Output "Installing Microsoft XPS Document Writer..." + Enable-WindowsOptionalFeature -Online -FeatureName "Printing-XPSServices-Features" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Remove Default Fax Printer +Function RemoveFaxPrinter { + Write-Output "Removing Default Fax Printer..." + Remove-Printer -Name "Fax" -ErrorAction SilentlyContinue +} + +# Add Default Fax Printer +Function AddFaxPrinter { + Write-Output "Adding Default Fax Printer..." + Add-Printer -Name "Fax" -DriverName "Microsoft Shared Fax Driver" -PortName "SHRFAX:" -ErrorAction SilentlyContinue +} + +# Uninstall Windows Fax and Scan Services - Not applicable to Server +Function UninstallFaxAndScan { + Write-Output "Uninstalling Windows Fax and Scan Services..." + Disable-WindowsOptionalFeature -Online -FeatureName "FaxServicesClientPackage" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +# Install Windows Fax and Scan Services - Not applicable to Server +Function InstallFaxAndScan { + Write-Output "Installing Windows Fax and Scan Services..." + Enable-WindowsOptionalFeature -Online -FeatureName "FaxServicesClientPackage" -NoRestart -WarningAction SilentlyContinue | Out-Null +} + +########## +#endregion Application Tweaks +########## + + + +########## +#region Server specific Tweaks +########## + +# Hide Server Manager after login +Function HideServerManagerOnLogin { + Write-Output "Hiding Server Manager after login..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Server\ServerManager")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Server\ServerManager" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Server\ServerManager" -Name "DoNotOpenAtLogon" -Type DWord -Value 1 +} + +# Show Server Manager after login +Function ShowServerManagerOnLogin { + Write-Output "Showing Server Manager after login..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Server\ServerManager" -Name "DoNotOpenAtLogon" -ErrorAction SilentlyContinue +} + +# Disable Shutdown Event Tracker +Function DisableShutdownTracker { + Write-Output "Disabling Shutdown Event Tracker..." + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Reliability")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Reliability" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Reliability" -Name "ShutdownReasonOn" -Type DWord -Value 0 +} + +# Enable Shutdown Event Tracker +Function EnableShutdownTracker { + Write-Output "Enabling Shutdown Event Tracker..." + Remove-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Reliability" -Name "ShutdownReasonOn" -ErrorAction SilentlyContinue +} + +# Disable password complexity and maximum age requirements +Function DisablePasswordPolicy { + Write-Output "Disabling password complexity and maximum age requirements..." + $tmpfile = New-TemporaryFile + secedit /export /cfg $tmpfile /quiet + (Get-Content $tmpfile).Replace("PasswordComplexity = 1", "PasswordComplexity = 0").Replace("MaximumPasswordAge = 42", "MaximumPasswordAge = -1") | Out-File $tmpfile + secedit /configure /db "$env:SYSTEMROOT\security\database\local.sdb" /cfg $tmpfile /areas SECURITYPOLICY | Out-Null + Remove-Item -Path $tmpfile +} + +# Enable password complexity and maximum age requirements +Function EnablePasswordPolicy { + Write-Output "Enabling password complexity and maximum age requirements..." + $tmpfile = New-TemporaryFile + secedit /export /cfg $tmpfile /quiet + (Get-Content $tmpfile).Replace("PasswordComplexity = 0", "PasswordComplexity = 1").Replace("MaximumPasswordAge = -1", "MaximumPasswordAge = 42") | Out-File $tmpfile + secedit /configure /db "$env:SYSTEMROOT\security\database\local.sdb" /cfg $tmpfile /areas SECURITYPOLICY | Out-Null + Remove-Item -Path $tmpfile +} + +# Disable Ctrl+Alt+Del requirement before login +Function DisableCtrlAltDelLogin { + Write-Output "Disabling Ctrl+Alt+Del requirement before login..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "DisableCAD" -Type DWord -Value 1 +} + +# Enable Ctrl+Alt+Del requirement before login +Function EnableCtrlAltDelLogin { + Write-Output "Enabling Ctrl+Alt+Del requirement before login..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" -Name "DisableCAD" -Type DWord -Value 0 +} + +# Disable Internet Explorer Enhanced Security Configuration (IE ESC) +Function DisableIEEnhancedSecurity { + Write-Output "Disabling Internet Explorer Enhanced Security Configuration (IE ESC)..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" -Name "IsInstalled" -Type DWord -Value 0 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" -Name "IsInstalled" -Type DWord -Value 0 +} + +# Enable Internet Explorer Enhanced Security Configuration (IE ESC) +Function EnableIEEnhancedSecurity { + Write-Output "Enabling Internet Explorer Enhanced Security Configuration (IE ESC)..." + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" -Name "IsInstalled" -Type DWord -Value 1 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" -Name "IsInstalled" -Type DWord -Value 1 +} + +# Enable Audio +Function EnableAudio { + Write-Output "Enabling Audio..." + Set-Service "Audiosrv" -StartupType Automatic + Start-Service "Audiosrv" -WarningAction SilentlyContinue +} + +# Disable Audio +Function DisableAudio { + Write-Output "Disabling Audio..." + Stop-Service "Audiosrv" -WarningAction SilentlyContinue + Set-Service "Audiosrv" -StartupType Manual +} + +########## +#endregion Server specific Tweaks +########## + + + +########## +#region Unpinning +########## + +# Unpin all Start Menu tiles - Note: This function has no counterpart. You have to pin the tiles back manually. +Function UnpinStartMenuTiles { + Write-Output "Unpinning all Start Menu tiles..." + If ([System.Environment]::OSVersion.Version.Build -ge 15063 -And [System.Environment]::OSVersion.Version.Build -le 16299) { + Get-ChildItem -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount" -Include "*.group" -Recurse | ForEach-Object { + $data = (Get-ItemProperty -Path "$($_.PsPath)\Current" -Name "Data").Data -Join "," + $data = $data.Substring(0, $data.IndexOf(",0,202,30") + 9) + ",0,202,80,0,0" + Set-ItemProperty -Path "$($_.PsPath)\Current" -Name "Data" -Type Binary -Value $data.Split(",") + } + } ElseIf ([System.Environment]::OSVersion.Version.Build -ge 17134) { + $key = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\CloudStore\Store\Cache\DefaultAccount\*start.tilegrid`$windows.data.curatedtilecollection.tilecollection\Current" + $data = $key.Data[0..25] + ([byte[]](202,50,0,226,44,1,1,0,0)) + Set-ItemProperty -Path $key.PSPath -Name "Data" -Type Binary -Value $data + Stop-Process -Name "ShellExperienceHost" -Force -ErrorAction SilentlyContinue + } +} + +# Unpin all Taskbar icons - Note: This function has no counterpart. You have to pin the icons back manually. +Function UnpinTaskbarIcons { + Write-Output "Unpinning all Taskbar icons..." + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -Name "Favorites" -Type Binary -Value ([byte[]](255)) + Remove-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -Name "FavoritesResolve" -ErrorAction SilentlyContinue +} + +########## +#endregion Unpinning +########## + + + +########## +#region Auxiliary Functions +########## + +# Wait for key press +Function WaitForKey { + Write-Output "`nPress any key to continue..." + [Console]::ReadKey($true) | Out-Null +} + +# Restart computer +Function Restart { + Write-Output "Restarting..." + Restart-Computer +} + +########## +#endregion Auxiliary Functions +########## + + + +# Export functions +Export-ModuleMember -Function *