diff options
| author | seth <[email protected]> | 2024-01-15 20:03:32 -0500 |
|---|---|---|
| committer | seth <[email protected]> | 2024-01-15 20:03:32 -0500 |
| commit | f66e6d6518958bb9aee28fa447e57f8a50ee78c5 (patch) | |
| tree | 7a23649939e1d593eae023fb9c46b48c437fb51a | |
initial commit
| -rw-r--r-- | .gitattributes | 3 | ||||
| -rw-r--r-- | LICENSE | 21 | ||||
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | debloat.ps1 | 181 | ||||
| -rw-r--r-- | install_apps.ps1 | 186 |
5 files changed, 394 insertions, 0 deletions
diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..1f10e82 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +* text=auto + +*.ps1 text eol=crlf @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024 seth + +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 new file mode 100644 index 0000000..baedcd4 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# windows-scripts + +small collection of scripts i use when (re)installing windows diff --git a/debloat.ps1 b/debloat.ps1 new file mode 100644 index 0000000..4543ef5 --- /dev/null +++ b/debloat.ps1 @@ -0,0 +1,181 @@ +<# +.SYNOPSIS + Post-install script for "debloating" Windows +.DESCRIPTION + Removes default apps, disables telemetry, services, and some other annoying things +.NOTES + Inspired by https://gist.github.com/mikepruett3/7ca6518051383ee14f9cf8ae63ba18a7 +#> + +$VerbosePreference = "Continue" + +function Add-Registry-Key { + param ( + [String]$Name, + [String]$Path, + [Microsoft.Win32.RegistryValueKind]$Type, + [System.Object]$Value + ) + + Write-Verbose -Message "Adding registry key $Path\$NAME" + if (-not(Test-Path -Path $Path)) { + Write-Verbose -Message "Creating registry path $Path" + New-Item -Path $Path -Force + } + New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $Type -Force +} + +function Add-HKLM-Key { + param ( + [String]$Name, + [String]$Path, + [Microsoft.Win32.RegistryValueKind]$Type, + [System.Object]$Value + ) + + Add-Registry-Key -Path "HKLM:\$Path" -Name $Name -Value $Value -Type $Type +} + +function Add-HKCU-Key { + param ( + [String]$Name, + [String]$Path, + [Microsoft.Win32.RegistryValueKind]$Type, + [System.Object]$Value + ) + + Add-Registry-Key -Path "HKCU:\$Path" -Name $Name -Value $Value -Type $Type +} + +function Remove-Default-Package { + param ( + [String]$Name + ) + + Write-Verbose -Message "Removing default package $Name" + Get-AppxProvisionedPackage -Online | Where-Object {$_.PackageName -Like $Name} | ForEach-Object { Remove-AppxProvisionedPackage -Online -PackageName $_.PackageName} + Write-Verbose -Message "Removing $Name from current user" + Get-AppxPackage $Name | Remove-AppxPackage +} + + +# actual start of the script :p +Write-Host "Starting post-install script!" + + +# --- Privacy/Usability Settings --- +# see https://learn.microsoft.com/en-us/windows/privacy/manage-connections-from-windows-operating-system-components-to-microsoft-services + +## Disable Cortana and Web Search +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "AllowCortana" -Type DWord -Value 0 +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "AllowSearchToUseLocation" -Type DWord -Value 0 +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "DisableWebSearch" -Type DWord -Value 1 +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Search" -Name "ConnectedSearchUseWeb" -Type DWord -Value 0 + +## Disable OneDrive +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Name "DisableFileSyncNGSC" -Type DWord -Value 1 +Add-HKLM-Key -Path "SOFTWARE\Microsoft\OneDrive" -Name "PreventNetworkTrafficPreUserSignIn" -Type DWord -Value 1 + +## Disable Advertising ID +Add-HKLM-Key -Path "SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo" -Name "Enabled" -Type DWord -Value 0 +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo" -Name "DisabledByGroupPolicy" -Type DWord -Value 1 +Add-HKLM-Key -Path "SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_TrackProgs" -Type DWord -Value 0 + +## Disable apps' access to some things +$app_access = @( + "LetAppsAccessLocation" + "LetAppsAccessContacts" + "LetAppsAccessCalendar" + "LetAppsAccessCallHistory" + "LetAppsAccessEmail" + "LetAppsAccessMessaging" + "LetAppsAccessPhone" + "LetAppsAccessMotion" + "LetAppsAccessTasks" + "LetAppsGetDiagnosticInfo" + "LetAppsActivateWithVoice" + "LetAppsActivateWithVoiceAboveLock" +) + +foreach ($access in $app_access) { + Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name $access -Type DWord -Value 2 +} + +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\Messaging" -Name "AllowMessageSync" -Type DWord -Value 0 + +## Disable Feedback & diagnostics +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "DoNotShowFeedbackNotifications" -Type DWord -Value 1 +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\DataCollection" -Name "AllowTelemetry" -Type DWord -Value 0 +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableWindowsConsumerFeatures" -Type DWord -Value 1 +Add-HKCU-Key -Path "SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableTailoredExperiencesWithDiagnosticData" -Type DWord -Value 1 + +## Disable Inking & Typing data collection +Add-HKCU-Key -Path "SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitTextCollection" -Type DWord -Value 1 +Add-HKCU-Key -Path "SOFTWARE\Microsoft\InputPersonalization" -Name "RestrictImplicitInkCollection" -Type DWord -Value 1 + +## Disable Activity History +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\System" -Name "EnableActivityFeed" -Type DWord -Value 0 +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\System" -Name "PublishUserActivities" -Type DWord -Value 0 +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\System" -Name "UploadUserActivities" -Type DWord -Value 0 + +## Disable Windows Defender sample submission +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows Defender\Spynet" -Name "SubmitSamplesConsent" -Type DWord -Value 2 + +## Disable News and interests +Add-HKLM-Key -Path "SOFTWARE\Policies\Microsoft\Windows\Windows Feeds" -Name "EnableFeeds" -Type DWord -Value 0 + +## Disable Personalized Experiences +Add-HKCU-Key -Path "SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableWindowsSpotlightFeatures" -Type DWord -Value 1 +Add-HKCU-Key -Path "SOFTWARE\Policies\Microsoft\Windows\CloudContent" -Name "DisableCloudOptimizedContent" -Type DWord -Value 1 + + +# --- Remove Default Packages --- +$packages = @( + "Microsoft.BingNews" + "Microsoft.BingWeather" + "Microsoft.BingFinance" + "Microsoft.BingSports" + "*.Twitter" + "Microsoft.Office.Sway" + "Microsoft.Office.OneNote" + "Microsoft.MicrosoftOfficeHub" + "Microsoft.SkypeApp" + "Microsoft.MicrosoftStickyNotes" +) + +foreach ($pkg in $packages) { + Remove-Default-Package -Name $pkg +} + + +# --- Disable Extra Services --- +## sourced from https://github.com/ChrisTitusTech/winutil +$services = @( + "AJRouter" + "Browser" + "BthAvctpSvc" + "diagnosticshub.standardcollector.service" + "DiagTrack" + "Fax" + "fhsvc" + "lmhosts" + "PhoneSvc" + "RemoteAccess" + "RemoteRegistry" + "RetailDemo" + # "wisvc" # Windows Insider, uncomment if you'll never use it + "WMPNetworkSvc" + "WPDBusEnum" +) + +foreach ($service in $services) { + Write-Verbose -Message "Disabling $service" + Get-Service -Name $service -ErrorAction SilentlyContinue | Set-Service -StartupType Manual -ErrorAction SilentlyContinue +} + + +# --- Disable Copilot --- +Add-HKCU-Key -Path "SOFTWARE\Policies\Microsoft\Windows\WindowsCopilot" -Name "TurnOffWindowsCopilot" -Type DWord -Value 1 + + +Write-Host "Done!" diff --git a/install_apps.ps1 b/install_apps.ps1 new file mode 100644 index 0000000..04faee1 --- /dev/null +++ b/install_apps.ps1 @@ -0,0 +1,186 @@ +<# +.SYNOPSIS + Post-install script for adding all my apps +#> + + +function Install-Winget-Package { + param ( + [String]$Package + ) + + if (! (winget list --exact -q $Package --accept-source-agreements --accept-package-agreements) ) { + Write-Verbose -Message "Installing $Package with winget" + winget install --exact --silent $Package + } else { + Write-Verbose -Message "Winget package $Package is already installed! Skipping" + } +} + +function Install-Scoop-Package { + param ( + [String]$Package + ) + + if (! (scoop info $Package).Installed ) { + Write-Verbose -Message "Installing $Package with scoop" + scoop install $Package + } else { + Write-Verbose -Message "Scoop package $Package is already installed! Skipping" + } +} + +function Get-File { + param ( + [String]$Output, + [String]$URL + ) + + Write-Versboe -Message "Downloading file from $URL" + Invoke-Webrequest -Uri $URL -OutFile $Output +} + +function Install-From-File { + param ( + [String]$Output, + [String]$Path + ) + + Get-File -Output $Path -URL $URL + if (Test-Path -Path $Path) { + Start-Process -FilePath $Path + Remove-Item -Path $Path + } else { + Write-Verbose -Message "$Path was not found! Skipping" + } +} + + +# --- This script does a lot so a warning is good --- +if ( (Read-Host -Prompt "Do you want to install packages through winget and scoop? [y/n]?").toLower() -ne "y") { + Write-Host "You didn't say yes! Bailing out..." + Exit +} + + +# --- Setup WinGet Packages --- + +## install winget if it's not already +## https://gist.github.com/crutkas/6c2096eae387e544bd05cde246f23901 +if (! (Get-AppxPackage -Name "Microsoft.DesktopAppInstaller") ) { + Write-Verbose -Message "Installing winget" + $releases_url = "https://api.github.com/repos/microsoft/winget-cli/releases/latest" + + [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 + $releases = Invoke-RestMethod -uri "$($releases_url)" + $latestRelease = $releases.assets | Where-Object { $_.browser_download_url.EndsWith("msixbundle") } | Select-Object -First 1 + + Add-AppxPackage -Path $latestRelease.browser_download_url +} + +$winget_packages = @( + "Hibbiki.Chromium" + "Ubisoft.Connect" + "Discord.Discord" + "ElectronicArts.EADesktop" + "EpicGames.EpicGamesLauncher" + "voidtools.Everything" + "valinet.ExplorerPatcher" + "Mozilla.Firefox" + "Gajim.Gajim" + "GOG.Galaxy" + "RyanGregg.GCFScape" + "GIMP.GIMP.Nightly" + "LOOT.LOOT" + "Mojang.MinecraftLauncher" + "MullvadVPN.MullvadVPN" + "M2Team.NanaZip" + "Jaquadro.NBTExplorer" + "nomacs.nomacs" + "Notepad++.Notepad++" + "TechPowerUp.NVCleanstall" + "OBSProject.OBSStudio" + "namazso.OpenHashTab" + "Microsoft.PowerShell" + "Microsoft.PowerToys" + "PrismLauncher.PrismLauncher" + "qBittorrent.qBittorrent" + "Spotify.Spotify" + "Valve.Steam" + "tailscale.tailscale" + "OneGal.Viper" + "Microsoft.VisualStudio.2022.BuildTools" + "Microsoft.VisualStudioCode" + "VideoLAN.VLC" + "RyanGregg.VTFEdit" +) + +foreach ($pkg in $winget_packages) { + Install-Winget-Package -Package $pkg +} + + +# --- Setup Scoop Packages --- + +Set-ExecutionPolicy RemoteSigned -Scope CurrentUser +## install scoop if it isn't already +if ( !(Get-Command -Name "scoop" -CommandType Application -ErrorAction SilentlyContinue | Out-Null) ) { + Write-Verbose -Message "Installing Scoop" + Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')) +} + +$scoop_packages = @( + "git" + "7-zip" + "cemu" + "crispy-doom" + "deno" + "dog" + "dolphin" + "dust" + "element" + "fd" + "ffmpeg" + "filelight" + "fnm" + "gh" + "gpg" + "handbrake" + "hwinfo" + "just" + "kdenlive" + "magic-wormhole" + "neovim" + "nicotine-plus" + "openrgb" + "pnpm" + "python" + "rclone" + "restic" + "retroarch" + "ripgrep" + "rustup-msvc" + "sccache" + "smartmontools" + "temurin17-jdk" + "temurin8-jre" + "yt-dlp" + "yuzu" + "zstd" +) + +foreach ($pkg in $scoop_packages) { + Install-Scoop-Package -Package $pkg +} + +# --- Install external apps --- +$file = New-TemporaryFile +Remove-Item -Path $file -Force +$temp_folder = New-Item -ItemType Directory -Path "$($ENV:Temp)\$($file.Name)" + +Install-From-File -Output "$temp_folder/OpenJDK16U-jdk_x64_windows_hotspot_16.0.2_7.msi" -URL "https://github.com/adoptium/temurin16-binaries/releases/download/jdk-16.0.2%2B7/OpenJDK16U-jdk_x64_windows_hotspot_16.0.2_7.msi" +Get-File -Output "$HOME/Downloads/rpcs3-v0.0.25-14495-8ac99680_win64.7z" -URL "https://github.com/RPCS3/rpcs3-binaries-win/releases/download/build-8ac99680962fc4c01dd561716f0b927d386bc7e8/rpcs3-v0.0.25-14495-8ac99680_win64.7z" +Install-From-File -Output "$temp_folder/Slippi-Launcher-Setup-2.7.0.exe" -URL "https://github.com/project-slippi/slippi-launcher/releases/download/v2.7.0/Slippi-Launcher-Setup-2.7.0.exe" + + +Write-Host "Done!" |
