Skip to content

Instantly share code, notes, and snippets.

@NickCraver
Last active August 1, 2024 16:19
Show Gist options
  • Save NickCraver/7ebf9efbfd0c3eab72e9 to your computer and use it in GitHub Desktop.
Save NickCraver/7ebf9efbfd0c3eab72e9 to your computer and use it in GitHub Desktop.
(In Progress) PowerShell Script I use to customize my machines in the same way for privacy, search, UI, etc.
##################
# Privacy Settings
##################
# Privacy: Let apps use my advertising ID: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 0
# To Restore:
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo -Name Enabled -Type DWord -Value 1
# Privacy: SmartScreen Filter for Store Apps: Disable
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 0
# To Restore:
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\AppHost -Name EnableWebContentEvaluation -Type DWord -Value 1
# WiFi Sense: HotSpot Sharing: Disable
Set-ItemProperty -Path HKLM:\Software\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting -Name value -Type DWord -Value 0
# WiFi Sense: Shared HotSpot Auto-Connect: Disable
Set-ItemProperty -Path HKLM:\Software\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots -Name value -Type DWord -Value 0
# Activity Tracking: Disable
@('EnableActivityFeed','PublishUserActivities','UploadUserActivities') |% { Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\System -Name $_ -Type DWord -Value 0 }
# Start Menu: Disable Bing Search Results
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name BingSearchEnabled -Type DWord -Value 0
# To Restore (Enabled):
# Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search -Name BingSearchEnabled -Type DWord -Value 1
# Start Menu: Disale Cortana (Commented out by default - this is personal preference)
# TODO: Figure this out - need another VM to test, mine's already disabled via domain, etc.
# Disable Telemetry (requires a reboot to take effect)
Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection -Name AllowTelemetry -Type DWord -Value 0
Get-Service DiagTrack,Dmwappushservice | Stop-Service | Set-Service -StartupType Disabled
############################
# Personal Preferences on UI
############################
# Change Explorer home screen back to "This PC"
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name LaunchTo -Type DWord -Value 1
# Change it back to "Quick Access" (Windows 10 default)
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced -Name LaunchTo -Type DWord -Value 2
# These make "Quick Access" behave much closer to the old "Favorites"
# Disable Quick Access: Recent Files
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShowRecent -Type DWord -Value 0
# Disable Quick Access: Frequent Folders
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShowFrequent -Type DWord -Value 0
# To Restore:
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShowRecent -Type DWord -Value 1
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer -Name ShowFrequent -Type DWord -Value 1
# Disable the Lock Screen (the one before password prompt - to prevent dropping the first character)
If (-Not (Test-Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization)) {
New-Item -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows -Name Personalization | Out-Null
}
Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization -Name NoLockScreen -Type DWord -Value 1
# To Restore:
#Set-ItemProperty -Path HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization -Name NoLockScreen -Type DWord -Value 1
# Use the Windows 7-8.1 Style Volume Mixer
If (-Not (Test-Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\MTCUVC")) {
New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion" -Name MTCUVC | Out-Null
}
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\MTCUVC" -Name EnableMtcUvc -Type DWord -Value 0
# To Restore (Windows 10 Style Volume Control):
#Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\MTCUVC" -Name EnableMtcUvc -Type DWord -Value 1
# Dark Theme for Windows (commenting out by default because this one's probbly a minority want)
# Note: the title bar text and such is still black with low contrast, and needs additional tweaks (it'll probably be better in a future build)
#If (-Not (Test-Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize)) {
# New-Item -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes -Name Personalize | Out-Null
#}
#Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Type DWord -Value 0
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Type DWord -Value 0
# To Restore (Light Theme):
#Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Type DWord -Value 1
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize -Name AppsUseLightTheme -Type DWord -Value 1
#################
# Windows Updates
#################
# Change Windows Updates to "Notify to schedule restart"
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name UxOption -Type DWord -Value 1
# To Restore (Automatic):
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings -Name UxOption -Type DWord -Value 0
# Disable P2P Update downlods outside of local network
Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config -Name DODownloadMode -Type DWord -Value 1
Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization -Name SystemSettingsDownloadMode -Type DWord -Value 3
# To restore (PCs on my local network and PCs on the internet)
#Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config -Name DODownloadMode -Type DWord -Value 3
#Set-ItemProperty -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization -Name SystemSettingsDownloadMode -Type DWord -Value 1
# To disable P2P update downloads completely:
#Set-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config -Name DODownloadMode -Type DWord -Value 0
###############################
# Windows 10 Metro App Removals
# These start commented out so you choose
# Just remove the # (comment in PowerShell) on the ones you want to remove
###############################
# Be gone, heathen!
#Get-AppxPackage king.com.CandyCrushSaga | Remove-AppxPackage
# Bing Weather, News, Sports, and Finance (Money):
#Get-AppxPackage Microsoft.BingWeather | Remove-AppxPackage
#Get-AppxPackage Microsoft.BingNews | Remove-AppxPackage
#Get-AppxPackage Microsoft.BingSports | Remove-AppxPackage
#Get-AppxPackage Microsoft.BingFinance | Remove-AppxPackage
# Xbox:
#Get-AppxPackage Microsoft.XboxApp | Remove-AppxPackage
# Windows Phone Companion
#Get-AppxPackage Microsoft.WindowsPhone | Remove-AppxPackage
# Solitaire Collection
#Get-AppxPackage Microsoft.MicrosoftSolitaireCollection | Remove-AppxPackage
# People
#Get-AppxPackage Microsoft.People | Remove-AppxPackage
# Groove Music
#Get-AppxPackage Microsoft.ZuneMusic | Remove-AppxPackage
# Movies & TV
#Get-AppxPackage Microsoft.ZuneVideo | Remove-AppxPackage
# OneNote
#Get-AppxPackage Microsoft.Office.OneNote | Remove-AppxPackage
# Photos
#Get-AppxPackage Microsoft.Windows.Photos | Remove-AppxPackage
# Sound Recorder
#Get-AppxPackage Microsoft.WindowsSoundRecorder | Remove-AppxPackage
# Mail & Calendar
#Get-AppxPackage microsoft.windowscommunicationsapps | Remove-AppxPackage
# Skype (Metro version)
#Get-AppxPackage Microsoft.SkypeApp | Remove-AppxPackage
@trawra
Copy link

trawra commented Jan 20, 2020

Awesome script Nick!
Thanks for sharing!

@Cobertos
Copy link

Cobertos commented Feb 15, 2020

This is awesome! Using a few of these in my dotfiles https://github.com/Cobertos/dotfiles/blob/master/bootstrap/cli.py#L122-L126 . Here's a snippet of the edits from the previous link

    # == WINDOWS ==
    #Set the communication ducking to 'Do Nothing'
    SetRegKey(winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Multimedia\\Audio', \
      'UserDuckingPreference', winreg.REG_DWORD, 3)() #Default is key not present
    #A lot from: https://gist.github.com/NickCraver/7ebf9efbfd0c3eab72e9
    #Privacy related
    # Disable "Allow advertisers to use my advertising ID", default 1
    SetRegKey(winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Windows\\CurrentVersion\\AdvertisingInfo', \
      'Enabled', winreg.REG_DWORD, 0)()
    # WiFi sense shares the password for the WiFi with contacts in Outlook, Skype, etc (wtf...?)
    # WiFi Sense: HotSpot Sharing: Disable, default 1
    SetRegKey(winreg.HKEY_LOCAL_MACHINE, 'Software\\Microsoft\\PolicyManager\\default\\WiFi\\AllowWiFiHotSpotReporting', \
      'value', winreg.REG_DWORD, 0)()
    # WiFi Sense: Shared HotSpot Auto-Connect: Disable, default 1
    SetRegKey(winreg.HKEY_LOCAL_MACHINE, 'Software\\Microsoft\\PolicyManager\\default\\WiFi\\AllowAutoConnectToWiFiSenseHotspots', \
      'value', winreg.REG_DWORD, 0)()
    # Disable Bing search results, rewards, etc in search, all really annoying default 1
    SetRegKey(winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Windows\\CurrentVersion\\Search', \
      'BingSearchEnabled', winreg.REG_DWORD, 0)()
    #Disable Activity sharing
    SetRegKey(winreg.HKEY_LOCAL_MACHINE, 'Software\\Policies\\Microsoft\\Windows\\System', \
      'EnableActivityFeed', winreg.REG_DWORD, 0)()
    SetRegKey(winreg.HKEY_LOCAL_MACHINE, 'Software\\Policies\\Microsoft\\Windows\\System', \
      'PublishUserActivities', winreg.REG_DWORD, 0)()
    SetRegKey(winreg.HKEY_LOCAL_MACHINE, 'Software\\Policies\\Microsoft\\Windows\\System', \
      'UploadUserActivities', winreg.REG_DWORD, 0)()
    #Functionality related
    #Explorer launch to "This PC" (1) instead of default "Quick Access" (2)
    SetRegKey(winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced', \
      'LaunchTo', winreg.REG_DWORD, 1)()
    #Disable Recent Items and Frequent Folders (to stop porn and other stuff from popping up)
    SetRegKey(winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer', \
      'ShowRecent', winreg.REG_DWORD, 0)()
    SetRegKey(winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer', \
      'ShowFrequent', winreg.REG_DWORD, 0)()
    #Show hidden files (show is 1, hide is 2)
    SetRegKey(winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced', \
      'Hidden', winreg.REG_DWORD, 1)() #Defaults to 2 (hidden)
    #Show file extensions (show is 0, hide is 1)
    SetRegKey(winreg.HKEY_CURRENT_USER, 'Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced', \
      'HideFileExt', winreg.REG_DWORD, 0)() #Defaults to 1 (hidden)
    #Disable Sticky Keys, Filter Key, Toggle Keys (I dont think these work until a restart?)
    #https://answers.microsoft.com/en-us/windows/forum/windows_vista-desktop/i-cant-turn-off-sticky-keys/a7c9fc02-2d0f-4db6-89fb-e36eca3e2ac7
    SetRegKey(winreg.HKEY_CURRENT_USER, 'Control Panel\\Accessibility\\StickyKeys', \
      'Flags', winreg.REG_SZ, '506')() #disable sticky keys
    SetRegKey(winreg.HKEY_CURRENT_USER, 'Control Panel\\Accessibility\\Keyboard Response', \
      'Flags', winreg.REG_SZ, '122')() #Disable filter keys
    SetRegKey(winreg.HKEY_CURRENT_USER, 'Control Panel\\Accessibility\\ToggleKeys', \
      'Flags', winreg.REG_SZ, '58')() #Disable toggle keys
    #Disable mouse precision
    #https://www.tenforums.com/tutorials/101691-turn-off-enhance-pointer-precision-windows.html
    SetRegKey(winreg.HKEY_CURRENT_USER, 'Control Panel\\Mouse', \
      'MouseSpeed', winreg.REG_SZ, '0')()
    SetRegKey(winreg.HKEY_CURRENT_USER, 'Control Panel\\Mouse', \
      'MouseThreshold1', winreg.REG_SZ, '0')()
    SetRegKey(winreg.HKEY_CURRENT_USER, 'Control Panel\\Mouse', \
      'MouseThreshold2', winreg.REG_SZ, '0')()

For things like Dark Mode, I found you might be able to change those with a .theme file instead, and then just point to a .theme file

https://docs.microsoft.com/en-us/windows/win32/controls/themesfileformat-overview#visual-styles-section

@basziee
Copy link

basziee commented Jun 1, 2021

Maybe this is something you guys want to add. You need to have WinGet installed or you can use Chocolatey with the script from here

$Programs = @(
    "Discord.Discord"
    "Git.Git"
    "Microsoft.AzureCLI"
    "Microsoft.DeploymentToolkit"
    "Microsoft.PowerToys"
    "Microsoft.VisualStudioCode"
    "Microsoft.WindowsTerminalPreview"
    "OpenJS.Nodejs"
    "RARLab.WinRAR"
)

$programs | ForEach-Object{winget install $_}

@andrewiankidd
Copy link

Quick thankyou for all of the above; which I am using bits of. Cheers
https://gitlab.com/andrewkidd/winInit/-/blob/master/tweaks/Remove-SubjectiveBloat.ps1

@CMoneyLean
Copy link

CMoneyLean commented Aug 9, 2022

This is probably a dumb question, but does this work on Windows 11 (Pro)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment