diff --git a/bloatware-apps.txt b/bloatware-apps.txt new file mode 100644 index 0000000..08063b3 --- /dev/null +++ b/bloatware-apps.txt @@ -0,0 +1,28 @@ +Microsoft.Windows.ParentalControls +Microsoft.Windows.PeopleExperienceHost +Microsoft.XboxGameCallableUI +Clipchamp.Clipchamp +Microsoft.BingNews +Microsoft.BingSearch +Microsoft.BingWeather +Microsoft.Edge.GameAssist +Microsoft.GamingApp +Microsoft.MicrosoftOfficeHub +Microsoft.MicrosoftSolitaireCollection +Microsoft.MicrosoftStickyNotes +Microsoft.WindowsCalculator +Microsoft.WindowsFeedbackHub +Microsoft.WindowsSoundRecorder +Microsoft.ZuneMusic +Microsoft.XboxIdentityProvider +Microsoft.ScreenSketch +Microsoft.Paint +Microsoft.StartExperiencesApp +Microsoft.WidgetsPlatformRuntime +Microsoft.Todos +Microsoft.PowerAutomateDesktop +MicrosoftCorporationII.QuickAssist +Microsoft.YourPhone +Microsoft.XboxSpeechToTextOverlay +Microsoft.XboxGamingOverlay +Microsoft.Xbox.TCUI \ No newline at end of file diff --git a/configwinpc.ps1 b/configwinpc.ps1 new file mode 100644 index 0000000..58a0228 --- /dev/null +++ b/configwinpc.ps1 @@ -0,0 +1,392 @@ +# https://github.com/andrew-s-taylor/public/blob/main/De-Bloat/RemoveBloat.ps1 +# https://github.com/marlock9/edge-debloat/blob/main/edge-debloat.reg + +# Taskbar per tutti gli utenti +# Edge e bloatware per tutti gli utenti + +clear-Host + +# Open PowerShell as administrator +if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + Start-Process powershell -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs + exit +} + +Write-Host "" +Write-Host -ForegroundColor Yellow "SCRIPT +FOR CONFIGURING +AND +DEBLOATING +WINDOWS 11" + +########################################################################################## +# # +# Execution policy # +# # +########################################################################################## + +Write-Host "" + +# Check the current execution policy +$currentPolicy = Get-ExecutionPolicy -Scope LocalMachine + +# Define the desired execution policy +$desiredPolicy = "RemoteSigned" + +# If the current policy is not the desired one, change it +if ($currentPolicy -ne $desiredPolicy) { + # Change the policy (requires admin rights) + Set-ExecutionPolicy -ExecutionPolicy $desiredPolicy -Scope LocalMachine -Force | Out-Null + + # Confirm the change + Write-Host -ForegroundColor Yellow "Execution policy changed to '$desiredPolicy'." +} else { + Write-Host -ForegroundColor DarkGreen "Current execution policy is already set to '$currentPolicy'." +} + +# Sleep for 5 seconds +Start-Sleep -Seconds 5 + +clear-Host + +########################################################################################## +# # +# Software # +# # +########################################################################################## + +# https://winstall.app/ - Browse the winget repository + +Write-Host "" +Write-Host -ForegroundColor Yellow ">>> Upgrade packages... <<<" +winget upgrade --all --disable-interactivity +Write-Host "" +Write-Host -ForegroundColor Yellow ">>> Install default software... <<<" +winget install --disable-interactivity Microsoft.PowerShell Adobe.Acrobat.Reader.64-bit IZArc.IZArc Oracle.JavaRuntimeEnvironment Google.Chrome 7zip.7zip Microsoft.VCRedist.2010.x64 --source winget +Write-Host "" + +########################################################################################## +# # +# Taskbar # +# # +########################################################################################## + +# Taskbar Adjustment +Write-Host -ForegroundColor Yellow ">>> Manage Taskbar <<<" +Write-Host "" +Write-Host -ForegroundColor DarkGray ">>> Set left align <<<" +New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAl" -Value "0" -Type DWORD -Force | Out-Null + +Write-Host -ForegroundColor DarkGray ">>> Hide search <<<" +New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" -Name "SearchBoxTaskbarMode" -Value "0" -Type DWORD -Force | Out-Null + +Write-Host -ForegroundColor DarkGray ">>> Hide TaskView button <<<" +New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Value "0" -Type DWORD -Force | Out-Null + +Write-Host -ForegroundColor DarkGray ">>> Disable widgets in the taskbar <<<" +Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarWidgetsEnabled" -Value "0" | Out-Null + +Write-Host -ForegroundColor DarkGray ">>> Disable the 'Windows + W' keyboard shortcut to open widgets <<<" +Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer" -Name "ShowWindowsW" -Value "0" | Out-Null + +Write-Host -ForegroundColor DarkGray ">>> Removes Chat from the Taskbar <<<" +New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarMn" -Value "0" -PropertyType DWORD -Force | Out-Null + +Write-Host -ForegroundColor DarkGray ">>> Disabling 'Recommended' section <<<" +New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_IrisRecommendations" -Value "0" -Type DWORD -Force | Out-Null +New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_TrackDocs" -Value "0" -Type DWORD -Force | Out-Null +New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Value "1" -Type DWORD -Force | Out-Null +Write-Host "" + +$taskbarDa_path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" +If (Test-Path $taskbarDa_path\TaskbarDa) { + Remove-ItemProperty "$taskbarDa_path" -Name "TaskbarDa" -Force | Out-Null +} + +########################################################################################## +# # +# Explorer # +# # +########################################################################################## + +Write-Host -ForegroundColor Yellow ">>> Configure File Explorer <<<" +Write-Host "" +Write-Host -ForegroundColor DarkGray ">>> Set File Explorer to Open to This PC Instead of Quick Access <<<" +New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "LaunchTo" -Value "1" -Type DWORD -Force | Out-Null + +Write-Host -ForegroundColor DarkGray ">>> Enable Compact View <<<" +New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "UseCompactMode" -Value "1" -Force | Out-Null + +Write-Host -ForegroundColor DarkGray ">>> Show file extensions in Explorer <<<" +New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "HideFileExt" -Value "0" -Type DWORD -Force | Out-Null + +########################################################################################## +# # +# Spotlight # +# # +########################################################################################## + +Write-Host "" +Write-Host -ForegroundColor Yellow ">>> Disable Spotlight <<<" + +Write-Host "" +Write-Host -ForegroundColor DarkGray ">>> Disabling Windows Spotlight on lockscreen <<<" +$spotlight = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" +If (Test-Path $spotlight) { + Set-ItemProperty $spotlight -Name "RotatingLockScreenOverlayEnabled" -Value "0" + Set-ItemProperty $spotlight -Name "RotatingLockScreenEnabled" -Value "0" +} + +Write-Host -ForegroundColor DarkGray ">>> Disabling Windows Spotlight on background <<<" +$spotlight = "HKCU:\Software\Policies\Microsoft\Windows\CloudContent" +If (Test-Path $spotlight) { + Set-ItemProperty $spotlight -Name "DisableSpotlightCollectionOnDesktop" -Value "1" + Set-ItemProperty $spotlight -Name "DisableWindowsSpotlightFeatures" -Value "1" +} + +Write-Host "" +Write-Host -ForegroundColor Yellow ">>> Disable Notifications on Lock Screen <<<" +New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings" -Name "NOC_GLOBAL_SETTING_ALLOW_TOASTS_ABOVE_LOCK" -Value "0" -Type DWORD -Force | Out-Null +New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PushNotifications" -Name "LockScreenToastEnabled" -Value "0" -Type DWORD -Force | Out-Null + +# Create a temporary folder for export +$exportPath = "C:\temp" +if (-Not (Test-Path $exportPath)) { + New-Item -ItemType Directory -Path $exportPath | Out-Null +} + +########################################################################################## +# # +# Control Panel # +# # +########################################################################################## + +Write-Host "" +Write-Host -ForegroundColor DarkGray ">>> Change Control Panel View <<<" +New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" -Name "AllItemsIconView" -Value "1" -Type DWORD -Force | Out-Null +New-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" -Name "StartupPage" -Value "1" -Type DWORD -Force | Out-Null +New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" -Name "AllItemsIconView" -Value "1" -Type DWORD -Force | Out-Null +New-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel" -Name "StartupPage" -Value "1" -Type DWORD -Force | Out-Null +Write-Host "" + +########################################################################################## +# # +# Edge # +# # +########################################################################################## + +Write-Host -ForegroundColor Yellow ">>> Disable Microsoft Edge First Run Welcome Page <<<" +# Set variables to indicate value and key to set +$RegistryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Edge" +$Name = "HideFirstRunExperience" +$Value = "1" +# Create the key if it does not exist +If (-NOT (Test-Path $RegistryPath)) { + New-Item -Path $RegistryPath -Force | Out-Null +} +# Now set the value +New-ItemProperty -Path $RegistryPath -Name $Name -Value $Value -PropertyType DWORD -Force | Out-Null +Write-Host "" + +########################################################################################## +# # +# Export Registry # +# # +########################################################################################## + +# Export the registry keys +Write-Host -ForegroundColor DarkGray ">>> Exporting registry settings... <<<" + +reg export "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" "$exportPath\TaskbarSettings.reg" /y | Out-Null +reg export "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Search" "$exportPath\SearchSettings.reg" /y | Out-Null + +Write-Host -ForegroundColor DarkGray ">>> Importing registry settings to Default Profile <<<" + +# Copy the registry files to the default profile +Copy-Item "$exportPath\TaskbarSettings.reg" "C:\Users\Default\Desktop" +Copy-Item "$exportPath\SearchSettings.reg" "C:\Users\Default\Desktop" + +# Remove the temporary folder +Remove-Item -Path $exportPath -Recurse -Force + +Write-Host -ForegroundColor DarkGray ">>> Unpin Microsoft Store <<<" +((New-Object -Com Shell.Application).NameSpace('shell:::{4234d49b-0245-4df3-b780-3893943456e1}').Items() | ?{$_.Name -eq "Microsoft Store"}).Verbs() | ?{$_.Name.replace('&','') -match 'Unpin from taskbar'} | %{$_.DoIt(); $exec = $true} +Write-Host "" + +########################################################################################## +# # +# Power Plan # +# # +########################################################################################## + +Write-Host -ForegroundColor Yellow ">>> Power Plan <<<" +Write-Host "" +Write-Host -ForegroundColor DarkGray ">>> Activate High performance power plan <<<" +$powerPlan = Get-WmiObject -Namespace root\cimv2\power -Class Win32_PowerPlan -Filter "ElementName = 'High Performance'" +$powerPlan.Activate() + +# AC power +powercfg -change -monitor-timeout-ac 10 +powercfg -change -standby-timeout-ac 10 +powercfg -change -hibernate-timeout-ac 0 +powercfg -change -disk-timeout-ac 0 +# On battery +powercfg -change -monitor-timeout-dc 10 +powercfg -change -standby-timeout-dc 10 +powercfg -change -hibernate-timeout-dc 0 +powercfg -change -disk-timeout-dc 0 +powercfg /hibernate off + +# Set the power button behavior for AC power to "Shut down" +Write-Host -ForegroundColor DarkGray ">>> Setting the power button behavior to 'Shut down' <<<" +powercfg -setacvalueindex SCHEME_CURRENT SUB_BUTTONS PBUTTONACTION 3 +powercfg -setdcvalueindex SCHEME_CURRENT SUB_BUTTONS PBUTTONACTION 3 +# Set the sleep button behavior to "Do nothing" +Write-Host -ForegroundColor DarkGray ">>> Setting the sleep button behavior to 'Do nothing' <<<" +# Set the sleep button behavior for battery power to "Do nothing" +powercfg /SETACVALUEINDEX SCHEME_CURRENT SUB_BUTTONS SBUTTONACTION 0 +powercfg /SETDCVALUEINDEX SCHEME_CURRENT SUB_BUTTONS SBUTTONACTION 0 + +Write-Host -ForegroundColor DarkGray ">>> Disabling fast startup <<<" +Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Power" -Name HiberbootEnabled -Value "0" -Force | Out-Null + +Write-Host -ForegroundColor DarkGray ">>> Disable Energy-Efficient Ethernet <<<" +$adapter = Get-NetAdapter | Where-Object { $_.Name -eq "Ethernet" } +Disable-NetAdapterPowerManagement -Name $adapter.Name -NoRestart +Set-ItemProperty -Path ("HKLM:\SYSTEM\CurrentControlSet\Control\Class\{0}\{1}" -f "{4D36E972-E325-11CE-BFC1-08002BE10318}", $idNIC) -Name "PnPCapabilities" -Value "24" -Type DWORD -Force | Out-Null +Write-Host "" + +########################################################################################## +# # +# Windows Update # +# # +########################################################################################## + +Write-Host -ForegroundColor Yellow ">>> Windows Update settings <<<" + +Write-Host "" +Write-Host -ForegroundColor DarkGray ">>> Enable 'Get updates for other Microsoft products' <<<" +# Check if the script is running as administrator +if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + Write-Error -ForegroundColor Red "This script must be run with administrator privileges." + exit +} + +try { + $UpdateServiceManager = New-Object -ComObject "Microsoft.Update.ServiceManager" + $ServiceID = "7971f918-a847-4430-9279-4a52d1efe18d" # GUID for Microsoft Update + $UpdateServiceManager.AddService2($ServiceID, 7, "") | Out-Null +} +catch { + Write-Error "An error occurred while configuring Microsoft Update: $($_.Exception.Message)" +} +Write-Host -ForegroundColor DarkGray ">>> Set the notification behavior for updates to 'Do not show any notifications (excluding restart notifications)' <<<" +$RegistryPath = "HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\Settings" +$RegistryName = "ConfigureNotificationsForWU" +$RegistryValue = 0 # Do not show any notifications (excluding restart notifications) + +# Explanation of values for ConfigureNotificationsForWU: +# 0: Do not show any notifications (excluding restart notifications) +# 1: Show standard notifications (includes restart alerts) +# 2: Notify for download and installation +# 3: Disable all notifications + +# Check if the script is running as administrator +if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { + Write-Error -ForegroundColor Red "This script must be run with administrator privileges." + exit +} + +try { + # Check if the registry path exists + if (-not (Test-Path -Path $RegistryPath)) { + Write-Warning "The registry path '$RegistryPath' does not exist." + Write-Host "Windows Update may need to be initialized." + exit + } + + # Set the registry value + Set-ItemProperty -Path $RegistryPath -Name $RegistryName -Value $RegistryValue -Force +} +catch { + Write-Error "An error occurred while modifying the registry: $($_.Exception.Message)" +} + +# Set "Do not restart if user is logged on" +Write-Host -ForegroundColor DarkGray ">>> Set 'Do not restart if user is logged on' <<<" + +# Define the value to disable automatic reboots when a user is logged on +$NoAutoRebootWithLoggedOnUsers = 1 +# Registry path for Windows Update +$WindowsUpdateRegistryPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" + +# Check if the registry key exists, otherwise create it +if (!(Test-Path $WindowsUpdateRegistryPath)) { + New-Item -Path $WindowsUpdateRegistryPath -Force | Out-Null +} + +# Set the NoAutoRebootWithLoggedOnUsers value +Set-ItemProperty -Path $WindowsUpdateRegistryPath -Name "NoAutoRebootWithLoggedOnUsers" -Value $NoAutoRebootWithLoggedOnUsers -Type DWORD | Out-Null + +# Check if the setting has been applied correctly +$CheckValue = Get-ItemProperty -Path $WindowsUpdateRegistryPath -Name "NoAutoRebootWithLoggedOnUsers" + +# Restart the Windows Update service to apply the change immediately +Restart-Service -Name "wuauserv" -Force | Out-Null + +# Restart File Explorer to apply the changes +taskkill /f /im explorer.exe | Out-Null +start explorer.exe | Out-Null + +# Checking for Available Updates +Install-Module -Name PSWindowsUpdate -Force -Confirm:$False +Write-Host "" +Write-Host -ForegroundColor Yellow ">>> Checking for Available Updates... <<<" +Get-WindowsUpdate +Write-Host "" + +# Installing Windows Updates +Write-Host -ForegroundColor Yellow ">>> Installing Windows Updates... <<<" +Install-WindowsUpdate -AcceptAll + +# Monitoring Update Installation +# Write-Host "" +# Get-WindowsUpdateLog +Write-Host "" + +########################################################################################## +# # +# Remove Bloatware # +# # +########################################################################################## + +Write-Host -ForegroundColor Yellow ">>> Starting the process to remove unnecessary bloatware applications... <<< `n" + +# Read the content of the bloatware-list.txt file +$appsToRemove = Get-Content (Join-Path $env:USERPROFILE "Desktop\bloatware-list.txt") + +# Remove the specified apps from the list +foreach ($app in $appsToRemove) { + try { + Get-AppxPackage -Name $app | Remove-AppxPackage -AllUsers -ErrorAction Stop + Write-Host "Removed: $app" + } catch { + Write-Host "Error removing: $app. Details: $_" + } +} + +Write-Host -ForegroundColor Yellow ">>> Uninstallation of Microsoft Office <<<" +Start-Process "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" "https://aka.ms/SaRA-officeUninstallFromPC" + +Write-Host "" +# Write-Host -ForegroundColor Yellow ">>> Retrieving the list of installed Win32 programs... <<<" +# List of Win32 programs +# Get-WmiObject -Class Win32_Product | Select-Object -Property Name + +# Show the message +Write-Host -ForegroundColor Cyan ">>> Press any key to continue... <<<" +# Wait for a key press +$null = $Host.UI.RawUI.ReadKey('NoEcho,IncludeKeyDown') + +Write-Host -ForegroundColor Red "Restart the system to apply the changes..." +Restart-Computer -Force