diff --git a/set.psm1 b/set.psm1 index 19d3e7d..f81fd13 100644 --- a/set.psm1 +++ b/set.psm1 @@ -1876,235 +1876,235 @@ Function SystemSettings { RemoveShortcutName - ########## - #region Taskbar Settings - ########## + ########## + #region Taskbar Settings + ########## - Function DisableNews { - Write-Host "Disabling News and Interest on Taskbar..." -NoNewline + Function DisableNews { + Write-Host "Disabling News and Interest on Taskbar..." -NoNewline - try { - # Test and create 'Windows Feeds' path if it doesn't exist - $winfeedsPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Feeds" - if (-not (Test-Path -Path $winfeedsPath)) { - New-Item -Path $winfeedsPath -ErrorAction Stop | Out-Null - } + try { + # Test and create 'Windows Feeds' path if it doesn't exist + $winfeedsPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Windows Feeds" + if (-not (Test-Path -Path $winfeedsPath)) { + New-Item -Path $winfeedsPath -ErrorAction Stop | Out-Null + } - # Set 'EnableFeeds' registry value to 0 - Set-ItemProperty -Path $winfeedsPath -Name "EnableFeeds" -Type DWord -Value 0 -ErrorAction Stop | Out-Null + # Set 'EnableFeeds' registry value to 0 + Set-ItemProperty -Path $winfeedsPath -Name "EnableFeeds" -Type DWord -Value 0 -ErrorAction Stop | Out-Null - # Disable news and interests in the taskbar - $taskbarFeedsPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds" - Set-ItemProperty -Path $taskbarFeedsPath -Name "ShellFeedsTaskbarViewMode" -Type DWord -Value 2 -ErrorAction Stop | Out-Null + # Disable news and interests in the taskbar + $taskbarFeedsPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Feeds" + Set-ItemProperty -Path $taskbarFeedsPath -Name "ShellFeedsTaskbarViewMode" -Type DWord -Value 2 -ErrorAction Stop | Out-Null - # Disable Show recommendations for tips, shortcuts, new apps - Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_IrisRecommendations" -Type DWord -Value 0 -ErrorAction Stop | Out-Null + # Disable Show recommendations for tips, shortcuts, new apps + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_IrisRecommendations" -Type DWord -Value 0 -ErrorAction Stop | Out-Null - # Start Menu Layout - Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Type DWord -Value 1 -ErrorAction Stop | Out-Null + # Start Menu Layout + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_Layout" -Type DWord -Value 1 -ErrorAction Stop | Out-Null - # Turn off "Show recently opened items in Start, Jump Lists, and File Explorer" - Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_TrackDocs" -Type DWord -Value 0 -ErrorAction Stop | Out-Null + # Turn off "Show recently opened items in Start, Jump Lists, and File Explorer" + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "Start_TrackDocs" -Type DWord -Value 0 -ErrorAction Stop | Out-Null - # Disable news and interests via Policies\Explorer - $newregistryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" - if (-not (Test-Path $newregistryPath)) { - New-Item -Path $newregistryPath -Force | Out-Null - } - Set-ItemProperty -Path $newregistryPath -Name "NoNewsAndInterests" -Value 1 -ErrorAction Stop - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable news and interests via Policies\Explorer + $newregistryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" + if (-not (Test-Path $newregistryPath)) { + New-Item -Path $newregistryPath -Force | Out-Null } - - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Set-ItemProperty -Path $newregistryPath -Name "NoNewsAndInterests" -Value 1 -ErrorAction Stop + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } - DisableNews + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + + DisableNews - Function HideTaskbarPeopleIcon { - Write-Host "Hiding People Icon from Taskbar..." -NoNewline - try { - 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 - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + Function HideTaskbarPeopleIcon { + Write-Host "Hiding People Icon from Taskbar..." -NoNewline + try { + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" | Out-Null } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name "PeopleBand" -Type DWord -Value 0 + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - HideTaskbarPeopleIcon + HideTaskbarPeopleIcon - Function HideTaskbarTaskviewIcon { - Write-Host "Hiding Taskview Icon from Taskbar..." -NoNewline - try { - Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Type DWord -Value 0 - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Function HideTaskbarTaskviewIcon { + Write-Host "Hiding Taskview Icon from Taskbar..." -NoNewline + try { + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowTaskViewButton" -Type DWord -Value 0 + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - HideTaskbarTaskviewIcon + HideTaskbarTaskviewIcon - Function HideTaskbarMultiTaskviewIcon { - Write-Host "Hiding MultiTaskview Icon from Taskbar..." -NoNewline - If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\")) { - New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\" | Out-Null - } - If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\AllUpView")) { - New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\AllUpView" | Out-Null - } - try { - New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\AllUpView" -Name "AllUpView" -Type DWord -Value 0 *>$null - New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\AllUpView" -Name "Remove TaskView" -Type DWord -Value 0 *>$null - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Function HideTaskbarMultiTaskviewIcon { + Write-Host "Hiding MultiTaskview Icon from Taskbar..." -NoNewline + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\" | Out-Null } + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\AllUpView")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\AllUpView" | Out-Null + } + try { + New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\AllUpView" -Name "AllUpView" -Type DWord -Value 0 *>$null + New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\MultitaskingView\AllUpView" -Name "Remove TaskView" -Type DWord -Value 0 *>$null + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - HideTaskbarMultiTaskviewIcon + HideTaskbarMultiTaskviewIcon - Function HideTaskbarSearch { - Write-Host "Hiding Taskbar Search Icon / Box..." -NoNewline - try { - Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "SearchboxTaskbarMode" -Type DWord -Value 0 - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Function HideTaskbarSearch { + Write-Host "Hiding Taskbar Search Icon / Box..." -NoNewline + try { + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search" -Name "SearchboxTaskbarMode" -Type DWord -Value 0 + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - HideTaskbarSearch + HideTaskbarSearch - Function RemoveTaskbarChat { - Write-Host "Removing Chat from Taskbar..." -NoNewline - try { - Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\" -Name "TaskbarMn" -Type DWord -Value 0 - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Function RemoveTaskbarChat { + Write-Host "Removing Chat from Taskbar..." -NoNewline + try { + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\" -Name "TaskbarMn" -Type DWord -Value 0 + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - RemoveTaskbarChat + RemoveTaskbarChat - Function RemoveTaskbarWidgets { - Write-Host "Removing Widgets from Taskbar..." -NoNewline - try { - Start-Process powershell -Verb runAs -ArgumentList '-Command "Set-ItemProperty -Path \"HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\" -Name \"TaskbarDa\" -Type DWord -Value 0"' - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Function RemoveTaskbarWidgets { + Write-Host "Removing Widgets from Taskbar..." -NoNewline + try { + Start-Process powershell -Verb runAs -ArgumentList '-Command "Set-ItemProperty -Path \"HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced\" -Name \"TaskbarDa\" -Type DWord -Value 0"' + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - RemoveTaskbarWidgets + RemoveTaskbarWidgets - Function TurnOffSuggestedContent { - Write-Host "Turning off suggested content in Settings..." -NoNewline - $suggestregPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" - $contentSettings = @( - "SubscribedContent-338393Enabled", - "SubscribedContent-353694Enabled", - "SubscribedContent-353696Enabled" - ) + Function TurnOffSuggestedContent { + Write-Host "Turning off suggested content in Settings..." -NoNewline + $suggestregPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" + $contentSettings = @( + "SubscribedContent-338393Enabled", + "SubscribedContent-353694Enabled", + "SubscribedContent-353696Enabled" + ) - try { - foreach ($setting in $contentSettings) { - Set-ItemProperty -Path $suggestregPath -Name $setting -Type DWord -Value 0 - } - - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + try { + foreach ($setting in $contentSettings) { + Set-ItemProperty -Path $suggestregPath -Name $setting -Type DWord -Value 0 } + + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + } - TurnOffSuggestedContent + TurnOffSuggestedContent - Function TaskbarAlwaysCombine { - try { - Write-Host "Taskbar Always Combine..." -NoNewline - New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarGlomLevel" -Value 0 -ErrorAction SilentlyContinue *>$null - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + Function TaskbarAlwaysCombine { + try { + Write-Host "Taskbar Always Combine..." -NoNewline + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarGlomLevel" -Value 0 -ErrorAction SilentlyContinue *>$null + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + } - TaskbarAlwaysCombine + TaskbarAlwaysCombine - Function TaskbarAlignLeft { - try { - Write-Host "Taskbar Aligns Left..." -NoNewline - New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAl" -Value "0" -PropertyType Dword *>$null - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + Function TaskbarAlignLeft { + try { + Write-Host "Taskbar Aligns Left..." -NoNewline + New-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarAl" -Value "0" -PropertyType Dword *>$null + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + } - TaskbarAlignLeft + TaskbarAlignLeft - Function EnableShowDesktop { - try { - Write-Host "Enabling Show Desktop Button..." -NoNewline - New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarSd" -Value 1 -ErrorAction SilentlyContinue *>$null - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + Function EnableShowDesktop { + try { + Write-Host "Enabling Show Desktop Button..." -NoNewline + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "TaskbarSd" -Value 1 -ErrorAction SilentlyContinue *>$null + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + } - EnableShowDesktop + EnableShowDesktop - function EnableEndTaskButton { - try { - Write-Host "Enabling End Task Button..." -NoNewline - $keyPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" - $subKey = "TaskbarDeveloperSettings" - $propertyName = "TaskbarEndTask" - $propertyValue = 1 - - if (-not (Test-Path -Path "$keyPath\$subKey")) { - New-Item -Path $keyPath -Name $subKey -Force *>$null - } + function EnableEndTaskButton { + try { + Write-Host "Enabling End Task Button..." -NoNewline + $keyPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" + $subKey = "TaskbarDeveloperSettings" + $propertyName = "TaskbarEndTask" + $propertyValue = 1 - Set-ItemProperty -Path "$keyPath\$subKey" -Name $propertyName -Value $propertyValue -Type DWord - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + if (-not (Test-Path -Path "$keyPath\$subKey")) { + New-Item -Path $keyPath -Name $subKey -Force *>$null } + + Set-ItemProperty -Path "$keyPath\$subKey" -Name $propertyName -Value $propertyValue -Type DWord + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - EnableEndTaskButton + EnableEndTaskButton - Function UnpinEverything { - Param( - [string]$RemoveUnpin - ) + Function UnpinEverything { + Param( + [string]$RemoveUnpin + ) - try { - Write-Host "Unpin all taskbar pins..." -NoNewline + try { + Write-Host "Unpin all taskbar pins..." -NoNewline - Function getExplorerVerb { - Param([string]$verb) - $getstring = @' + Function getExplorerVerb { + Param([string]$verb) + $getstring = @' [DllImport("kernel32.dll", CharSet = CharSet.Auto)] public static extern IntPtr GetModuleHandle(string lpModuleName); @@ -2118,1046 +2118,1046 @@ Function SystemSettings { return sb.ToString(); } '@ - $getstring = Add-Type $getstring -PassThru -Name GetStr -Using System.Text + $getstring = Add-Type $getstring -PassThru -Name GetStr -Using System.Text - if ($verb -eq "PinToTaskbar") { $getstring[0]::GetString(5386) } # String: Pin to Taskbar - if ($verb -eq "UnpinFromTaskbar") { $getstring[0]::GetString(5387) } # String: Unpin from taskbar - if ($verb -eq "PinToStart") { $getstring[0]::GetString(51201) } # String: Pin to start - if ($verb -eq "UnpinFromStart") { $getstring[0]::GetString(51394) } # String: Unpin from start - } + if ($verb -eq "PinToTaskbar") { $getstring[0]::GetString(5386) } # String: Pin to Taskbar + if ($verb -eq "UnpinFromTaskbar") { $getstring[0]::GetString(5387) } # String: Unpin from taskbar + if ($verb -eq "PinToStart") { $getstring[0]::GetString(51201) } # String: Pin to start + if ($verb -eq "UnpinFromStart") { $getstring[0]::GetString(51394) } # String: Unpin from start + } - Function ConfigureTaskbarPinningApp { - Param([string]$RemoveUnpin, [string]$Verb) - $myProcessName = Get-Process | Where-Object { $_.ID -eq $pid } | ForEach-Object { $_.ProcessName } - if (-not ($myProcessName -like "explorer")) { - return - } + Function ConfigureTaskbarPinningApp { + Param([string]$RemoveUnpin, [string]$Verb) + $myProcessName = Get-Process | Where-Object { $_.ID -eq $pid } | ForEach-Object { $_.ProcessName } + if (-not ($myProcessName -like "explorer")) { + return + } - } + } - ConfigureTaskbarPinningApp -RemoveUnpin $RemoveUnpin -Verb "UnpinFromTaskbar" + ConfigureTaskbarPinningApp -RemoveUnpin $RemoveUnpin -Verb "UnpinFromTaskbar" - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - UnpinEverything -RemoveUnpin "" + UnpinEverything -RemoveUnpin "" - ########## - #endregion Taskbar Settings - ########## + ########## + #endregion Taskbar Settings + ########## - } - elseif ($response -eq 'n' -or $response -eq 'N') { - Write-Host "[System Settings Cancelled]" -ForegroundColor Red -BackgroundColor Black - } - else { - Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." - SystemSettings - } } + elseif ($response -eq 'n' -or $response -eq 'N') { + Write-Host "[System Settings Cancelled]" -ForegroundColor Red -BackgroundColor Black + } + else { + Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." + SystemSettings + } +} - SystemSettings - - ########## - #endregion System Settings - ########## - - ########## - #region Privacy Settings - ########## - Function PrivacySettings { - Write-Host `n"---------Adjusting Privacy Settings" -ForegroundColor Blue -BackgroundColor Gray - - Write-Host `n"Do you want " -NoNewline - Write-Host "Privacy Settings?" -ForegroundColor Yellow -NoNewline - Write-Host "(y/n): " -ForegroundColor Green -NoNewline - $response = Read-Host - - if ($response -eq 'y' -or $response -eq 'Y') { - - # Disable Telemetry - Function DisableTelemetry { - Write-Host `n"Disabling Telemetry..." -NoNewline - - $registrySettings = @( - #HKLM - @{Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"; Name = "AllowTelemetry"; Type = "DWord"; Value = 0 }, - @{Path = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection"; Name = "AllowTelemetry"; Type = "DWord"; Value = 0 }, - @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"; Name = "LimitDiagnosticLogCollection"; Type = "DWord"; Value = 1 }, - @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"; Name = "DisableOneSettingsDownloads"; Type = "DWord"; Value = 1 }, - @{Path = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection"; Name = "MaxTelemetryAllowed"; Type = "DWord"; Value = 0 }, - @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"; Name = "AllowTelemetry"; Type = "DWord"; Value = 0 }, - @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PreviewBuilds"; Name = "AllowBuildPreview"; Type = "DWord"; Value = 0 }, - @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Software Protection Platform"; Name = "NoGenTicket"; Type = "DWord"; Value = 1 }, - @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\SQMClient\Windows"; Name = "CEIPEnable"; Type = "DWord"; Value = 0 }, - @{Path = "HKLM:\SOFTWARE\Microsoft\SQMClient\Windows"; Name = "CEIPEnable"; Type = "DWord"; Value = 0 }, - @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat"; Name = "AITEnable"; Type = "DWord"; Value = 0 }, - @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat"; Name = "DisableInventory"; Type = "DWord"; Value = 1 }, - @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\AppV\CEIP"; Name = "CEIPEnable"; Type = "DWord"; Value = 0 }, - @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\TabletPC"; Name = "PreventHandwritingDataSharing"; Type = "DWord"; Value = 1 }, - @{Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\TextInput"; Name = "AllowLinguisticDataCollection"; Type = "DWord"; Value = 0 }, - @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OOBE"; Name = "DisablePrivacyExperience"; Type = "Dword"; Value = "1" }, - @{Path = "HKLM:\SOFTWARE\Microsoft\MdmCommon\SettingValues"; Name = "LocationSyncEnabled"; Type = "Dword"; Value = "0" }, - @{Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"; Name = "Enabled"; Type = "Dword"; Value = "0" }, - @{Path = "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows NT\Terminal Services"; Name = "fAllowToGetHelp"; Type = "Dword"; Value = "0" }, - @{Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy"; Name = "TailoredExperiencesWithDiagnosticDataEnabled"; Type = "Dword"; Value = "0" }, - #HKCU - @{Path = "HKCU:\Software\Microsoft\Speech_OneCore\Settings\OnlineSpeechPrivacy"; Name = "HasAccepted"; Type = "Dword"; Value = "0" }, - @{Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack"; Name = "ShowedToastAtLevel"; Type = "Dword"; Value = "1" }, - @{Path = "HKCU:\Software\Microsoft\Input\TIPC"; Name = "Enabled"; Type = "Dword"; Value = "0" }, - @{Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Privacy"; Name = "TailoredExperiencesWithDiagnosticDataEnabled"; Type = "Dword"; Value = "0" }, - @{Path = "HKCU:\Software\Policies\Microsoft\Windows\CloudContent"; Name = "DisableTailoredExperiencesWithDiagnosticData"; Type = "Dword"; Value = "1" }, - @{Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo"; Name = "Enabled"; Type = "Dword"; Value = "0" }, - @{Path = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\EdgeUI"; Name = "DisableMFUTracking"; Type = "Dword"; Value = "1" } - ) +SystemSettings + +########## +#endregion System Settings +########## + +########## +#region Privacy Settings +########## +Function PrivacySettings { + Write-Host `n"---------Adjusting Privacy Settings" -ForegroundColor Blue -BackgroundColor Gray + + Write-Host `n"Do you want " -NoNewline + Write-Host "Privacy Settings?" -ForegroundColor Yellow -NoNewline + Write-Host "(y/n): " -ForegroundColor Green -NoNewline + $response = Read-Host + + if ($response -eq 'y' -or $response -eq 'Y') { + + # Disable Telemetry + Function DisableTelemetry { + Write-Host `n"Disabling Telemetry..." -NoNewline + + $registrySettings = @( + #HKLM + @{Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\DataCollection"; Name = "AllowTelemetry"; Type = "DWord"; Value = 0 }, + @{Path = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection"; Name = "AllowTelemetry"; Type = "DWord"; Value = 0 }, + @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"; Name = "LimitDiagnosticLogCollection"; Type = "DWord"; Value = 1 }, + @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"; Name = "DisableOneSettingsDownloads"; Type = "DWord"; Value = 1 }, + @{Path = "HKLM:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Policies\DataCollection"; Name = "MaxTelemetryAllowed"; Type = "DWord"; Value = 0 }, + @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection"; Name = "AllowTelemetry"; Type = "DWord"; Value = 0 }, + @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\PreviewBuilds"; Name = "AllowBuildPreview"; Type = "DWord"; Value = 0 }, + @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\CurrentVersion\Software Protection Platform"; Name = "NoGenTicket"; Type = "DWord"; Value = 1 }, + @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\SQMClient\Windows"; Name = "CEIPEnable"; Type = "DWord"; Value = 0 }, + @{Path = "HKLM:\SOFTWARE\Microsoft\SQMClient\Windows"; Name = "CEIPEnable"; Type = "DWord"; Value = 0 }, + @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat"; Name = "AITEnable"; Type = "DWord"; Value = 0 }, + @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat"; Name = "DisableInventory"; Type = "DWord"; Value = 1 }, + @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\AppV\CEIP"; Name = "CEIPEnable"; Type = "DWord"; Value = 0 }, + @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\TabletPC"; Name = "PreventHandwritingDataSharing"; Type = "DWord"; Value = 1 }, + @{Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\TextInput"; Name = "AllowLinguisticDataCollection"; Type = "DWord"; Value = 0 }, + @{Path = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OOBE"; Name = "DisablePrivacyExperience"; Type = "Dword"; Value = "1" }, + @{Path = "HKLM:\SOFTWARE\Microsoft\MdmCommon\SettingValues"; Name = "LocationSyncEnabled"; Type = "Dword"; Value = "0" }, + @{Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\AdvertisingInfo"; Name = "Enabled"; Type = "Dword"; Value = "0" }, + @{Path = "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows NT\Terminal Services"; Name = "fAllowToGetHelp"; Type = "Dword"; Value = "0" }, + @{Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Privacy"; Name = "TailoredExperiencesWithDiagnosticDataEnabled"; Type = "Dword"; Value = "0" }, + #HKCU + @{Path = "HKCU:\Software\Microsoft\Speech_OneCore\Settings\OnlineSpeechPrivacy"; Name = "HasAccepted"; Type = "Dword"; Value = "0" }, + @{Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Diagnostics\DiagTrack"; Name = "ShowedToastAtLevel"; Type = "Dword"; Value = "1" }, + @{Path = "HKCU:\Software\Microsoft\Input\TIPC"; Name = "Enabled"; Type = "Dword"; Value = "0" }, + @{Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Privacy"; Name = "TailoredExperiencesWithDiagnosticDataEnabled"; Type = "Dword"; Value = "0" }, + @{Path = "HKCU:\Software\Policies\Microsoft\Windows\CloudContent"; Name = "DisableTailoredExperiencesWithDiagnosticData"; Type = "Dword"; Value = "1" }, + @{Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\AdvertisingInfo"; Name = "Enabled"; Type = "Dword"; Value = "0" }, + @{Path = "HKCU:\SOFTWARE\Policies\Microsoft\Windows\EdgeUI"; Name = "DisableMFUTracking"; Type = "Dword"; Value = "1" } + ) - try { - foreach ($reg in $registrySettings) { - if (!(Test-Path $reg.Path)) { - New-Item -Path $reg.Path -Force | Out-Null - } - Set-ItemProperty -Path $reg.Path -Name $reg.Name -Type $reg.Type -Value $reg.Value -ErrorAction Stop + try { + foreach ($reg in $registrySettings) { + if (!(Test-Path $reg.Path)) { + New-Item -Path $reg.Path -Force | Out-Null } + Set-ItemProperty -Path $reg.Path -Name $reg.Name -Type $reg.Type -Value $reg.Value -ErrorAction Stop + } + + $tasks = @( + "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser", + "Microsoft\Windows\Application Experience\ProgramDataUpdater", + "Microsoft\Windows\Autochk\Proxy", + "Microsoft\Windows\Customer Experience Improvement Program\Consolidator", + "Microsoft\Windows\Customer Experience Improvement Program\UsbCeip", + "Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector", + "Microsoft\Office\Office ClickToRun Service Monitor", + "Microsoft\Office\OfficeTelemetryAgentFallBack2016", + "Microsoft\Office\OfficeTelemetryAgentLogOn2016" + ) - $tasks = @( - "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser", - "Microsoft\Windows\Application Experience\ProgramDataUpdater", - "Microsoft\Windows\Autochk\Proxy", - "Microsoft\Windows\Customer Experience Improvement Program\Consolidator", - "Microsoft\Windows\Customer Experience Improvement Program\UsbCeip", - "Microsoft\Windows\DiskDiagnostic\Microsoft-Windows-DiskDiagnosticDataCollector", - "Microsoft\Office\Office ClickToRun Service Monitor", - "Microsoft\Office\OfficeTelemetryAgentFallBack2016", - "Microsoft\Office\OfficeTelemetryAgentLogOn2016" - ) + foreach ($task in $tasks) { + Disable-ScheduledTask -TaskName $task -ErrorAction SilentlyContinue *>$null + } - foreach ($task in $tasks) { - Disable-ScheduledTask -TaskName $task -ErrorAction SilentlyContinue *>$null - } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + Write-Host $_.Exception.Message -ForegroundColor Red + } + } + DisableTelemetry + + # Block Telemetry Url's to host file + Function BlockUrlsToHost { + Write-Host "Blocking Telemetry in Host File..." -NoNewline + $file = "C:\Windows\System32\drivers\etc\hosts" + if ((Test-Path -Path $file) -and (Get-Item $file).IsReadOnly -eq $false) { + try { + # hosts file url + Invoke-WebRequest -Uri "https://raw.githubusercontent.com/caglaryalcin/block-windows-telemetry/main/host" -OutFile "$env:USERPROFILE\Desktop\host" + Move-Item -Path "$env:userprofile\Desktop\host" -Destination C:\windows\system32\drivers\etc\hosts -Force Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } catch { Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - Write-Host $_.Exception.Message -ForegroundColor Red } } - - DisableTelemetry - - # Block Telemetry Url's to host file - Function BlockUrlsToHost { - Write-Host "Blocking Telemetry in Host File..." -NoNewline - $file = "C:\Windows\System32\drivers\etc\hosts" - if ((Test-Path -Path $file) -and (Get-Item $file).IsReadOnly -eq $false) { - try { - # hosts file url - Invoke-WebRequest -Uri "https://raw.githubusercontent.com/caglaryalcin/block-windows-telemetry/main/host" -OutFile "$env:USERPROFILE\Desktop\host" - Move-Item -Path "$env:userprofile\Desktop\host" -Destination C:\windows\system32\drivers\etc\hosts -Force - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - } - else { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + else { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - BlockUrlsToHost + BlockUrlsToHost - # Disable Feedback - function DisableFeedback { - Write-Host "Disabling Feedback..." -NoNewline + # Disable Feedback + function DisableFeedback { + Write-Host "Disabling Feedback..." -NoNewline - try { - # Define registry keys and their values - $RegistryKeys = @{ - "HKCU:\Software\Microsoft\Siuf\Rules" = @{ - "PeriodInNanoSeconds" = 0 - "NumberOfSIUFInPeriod" = 0 - } - "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" = @{ - "DoNotShowFeedbackNotifications" = 1 - } + try { + # Define registry keys and their values + $RegistryKeys = @{ + "HKCU:\Software\Microsoft\Siuf\Rules" = @{ + "PeriodInNanoSeconds" = 0 + "NumberOfSIUFInPeriod" = 0 } - - # Apply registry changes - foreach ($Key in $RegistryKeys.Keys) { - if (-not (Test-Path $Key)) { - New-Item -Path $Key -Force | Out-Null - } - foreach ($Property in $RegistryKeys[$Key].Keys) { - Set-ItemProperty -Path $Key -Name $Property -Type DWord -Value $RegistryKeys[$Key][$Property] -ErrorAction Stop - } + "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DataCollection" = @{ + "DoNotShowFeedbackNotifications" = 1 } + } - # Disable scheduled tasks - $tasks = @("Microsoft\Windows\Feedback\Siuf\DmClient", "Microsoft\Windows\Feedback\Siuf\DmClientOnScenarioDownload") - foreach ($task in $tasks) { - $result = Disable-ScheduledTask -TaskName $task -ErrorAction SilentlyContinue - if ($null -eq $result) { throw "Task $task could not be disabled or not found." } + # Apply registry changes + foreach ($Key in $RegistryKeys.Keys) { + if (-not (Test-Path $Key)) { + New-Item -Path $Key -Force | Out-Null + } + foreach ($Property in $RegistryKeys[$Key].Keys) { + Set-ItemProperty -Path $Key -Name $Property -Type DWord -Value $RegistryKeys[$Key][$Property] -ErrorAction Stop } - - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - Write-Host $_.Exception.Message -ForegroundColor Red + + # Disable scheduled tasks + $tasks = @("Microsoft\Windows\Feedback\Siuf\DmClient", "Microsoft\Windows\Feedback\Siuf\DmClientOnScenarioDownload") + foreach ($task in $tasks) { + $result = Disable-ScheduledTask -TaskName $task -ErrorAction SilentlyContinue + if ($null -eq $result) { throw "Task $task could not be disabled or not found." } } + + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + Write-Host $_.Exception.Message -ForegroundColor Red } + } - DisableFeedback + DisableFeedback - # Disable Text Suggestions - Function DisableTextSuggestions { - Write-Host "Disabling Text Suggestions..." -NoNewline - if (-not (Test-Path "HKCU:\Software\Microsoft\TabletTip\1.7" )) { - New-Item -Path "HKCU:\Software\Microsoft\TabletTip\1.7" -Force *>$null - } + # Disable Text Suggestions + Function DisableTextSuggestions { + Write-Host "Disabling Text Suggestions..." -NoNewline + if (-not (Test-Path "HKCU:\Software\Microsoft\TabletTip\1.7" )) { + New-Item -Path "HKCU:\Software\Microsoft\TabletTip\1.7" -Force *>$null + } - Set-ItemProperty -Path "HKCU:\Software\Microsoft\TabletTip\1.7" -Name "EnableTextPrediction" -Value 0 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - - DisableTextSuggestions + Set-ItemProperty -Path "HKCU:\Software\Microsoft\TabletTip\1.7" -Name "EnableTextPrediction" -Value 0 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - # Disable Windows Error Reporting - Function DisableErrorReporting { - Write-Host "Disabling Windows Error Reporting..." -NoNewline - If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting")) { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Force | Out-Null - } + DisableTextSuggestions - Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name "Disabled" -Value 1 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + # Disable Windows Error Reporting + Function DisableErrorReporting { + Write-Host "Disabling Windows Error Reporting..." -NoNewline + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Force | Out-Null } - DisableErrorReporting + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\Windows Error Reporting" -Name "Disabled" -Value 1 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - # Disable backup of text messages into the cloud - Function DisableTextMessageBackup { - Write-Host "Disabling Backup of Text Messages into the Cloud..." -NoNewline - try { - If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Messaging")) { - New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Messaging" -Force | Out-Null - } - Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Messaging" -Name "AllowMessageSync" -Type DWord -Value 0 -ErrorAction Stop | Out-Null - - If (!(Test-Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\Messaging")) { - New-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\Messaging" -Force | Out-Null - } - Set-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\Messaging" -Name "AllowMessageSync" -Type DWord -Value 0 -ErrorAction Stop | Out-Null - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + DisableErrorReporting + + # Disable backup of text messages into the cloud + Function DisableTextMessageBackup { + Write-Host "Disabling Backup of Text Messages into the Cloud..." -NoNewline + try { + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Messaging")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Messaging" -Force | Out-Null } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Messaging" -Name "AllowMessageSync" -Type DWord -Value 0 -ErrorAction Stop | Out-Null + + If (!(Test-Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\Messaging")) { + New-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\Messaging" -Force | Out-Null } + Set-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\Messaging" -Name "AllowMessageSync" -Type DWord -Value 0 -ErrorAction Stop | Out-Null + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableTextMessageBackup + DisableTextMessageBackup - # Disable sharing of handwriting error reports - Function DisableHandwritingErrorReports { - Write-Host "Disabling Sharing of Handwriting Error Reports..." -NoNewline - try { - If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\HandwritingErrorReports")) { - New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\HandwritingErrorReports" -Force | Out-Null - } - Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\HandwritingErrorReports" -Name "PreventHandwritingErrorReports" -Type DWord -Value 1 -ErrorAction Stop | Out-Null - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable sharing of handwriting error reports + Function DisableHandwritingErrorReports { + Write-Host "Disabling Sharing of Handwriting Error Reports..." -NoNewline + try { + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\HandwritingErrorReports")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\HandwritingErrorReports" -Force | Out-Null } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\HandwritingErrorReports" -Name "PreventHandwritingErrorReports" -Type DWord -Value 1 -ErrorAction Stop | Out-Null + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + } - DisableHandwritingErrorReports - - # Disable password reveal button - Function DisablePasswordRevealButton { - Write-Host "Disabling Password Reveal Button..." -NoNewline - try { - If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredUI")) { - New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredUI" -Force | Out-Null - } - Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredUI" -Name "DisablePasswordReveal" -Type DWord -Value 1 -ErrorAction Stop | Out-Null - - If (!(Test-Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\CredUI")) { - New-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\CredUI" -Force | Out-Null - } - Set-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\CredUI" -Name "DisablePasswordReveal" -Type DWord -Value 1 -ErrorAction Stop | Out-Null + DisableHandwritingErrorReports - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + # Disable password reveal button + Function DisablePasswordRevealButton { + Write-Host "Disabling Password Reveal Button..." -NoNewline + try { + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredUI")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredUI" -Force | Out-Null } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\CredUI" -Name "DisablePasswordReveal" -Type DWord -Value 1 -ErrorAction Stop | Out-Null + + If (!(Test-Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\CredUI")) { + New-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\CredUI" -Force | Out-Null } + Set-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\CredUI" -Name "DisablePasswordReveal" -Type DWord -Value 1 -ErrorAction Stop | Out-Null + + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisablePasswordRevealButton + DisablePasswordRevealButton - # Disable the transfer of the clipboard to other devices via the cloud - Function DisableClipboardSharing { - Write-Host "Disabling Clipboard Sharing..." -NoNewline - try { - If (!(Test-Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\System")) { - New-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\System" -Force | Out-Null - } - Set-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\System" -Name "AllowCrossDeviceClipboard" -Type DWord -Value 0 -ErrorAction Stop | Out-Null - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable the transfer of the clipboard to other devices via the cloud + Function DisableClipboardSharing { + Write-Host "Disabling Clipboard Sharing..." -NoNewline + try { + If (!(Test-Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\System")) { + New-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\System" -Force | Out-Null } + Set-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\System" -Name "AllowCrossDeviceClipboard" -Type DWord -Value 0 -ErrorAction Stop | Out-Null + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableClipboardSharing + DisableClipboardSharing - # Disable functionality to locate the system - Function Disablelocatesystem { - Write-Host "Disabling Functionality to Locate the System..." -NoNewline - try { - If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Bluetooth")) { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Bluetooth" -Force | Out-Null - } - Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Bluetooth" -Name "DisableWindowsLocationProvider" -Type DWord -Value 1 -ErrorAction Stop | Out-Null - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable functionality to locate the system + Function Disablelocatesystem { + Write-Host "Disabling Functionality to Locate the System..." -NoNewline + try { + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Bluetooth")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Bluetooth" -Force | Out-Null } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Bluetooth" -Name "DisableWindowsLocationProvider" -Type DWord -Value 1 -ErrorAction Stop | Out-Null + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + } - Disablelocatesystem + Disablelocatesystem - # Disable ads via Bluetooth - Function AdsviaBluetooth { - Write-Host "Disabling Ads via Bluetooth..." -NoNewline - try { - If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Bluetooth")) { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Bluetooth" -Force | Out-Null - } - Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Bluetooth" -Name "AllowAdvertising" -Type DWord -Value 0 -ErrorAction Stop | Out-Null - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable ads via Bluetooth + Function AdsviaBluetooth { + Write-Host "Disabling Ads via Bluetooth..." -NoNewline + try { + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Bluetooth")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Bluetooth" -Force | Out-Null } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\current\device\Bluetooth" -Name "AllowAdvertising" -Type DWord -Value 0 -ErrorAction Stop | Out-Null + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - AdsviaBluetooth + AdsviaBluetooth - # Disable Activity History feed in Task View - Function DisableActivityHistory { - Write-Host "Disabling Activity History..." -NoNewline - $settings = @{ - "EnableActivityFeed" = 0 - "PublishUserActivities" = 0 - "UploadUserActivities" = 0 - "AllowCrossDeviceClipboard" = 0 - } + # Disable Activity History feed in Task View + Function DisableActivityHistory { + Write-Host "Disabling Activity History..." -NoNewline + $settings = @{ + "EnableActivityFeed" = 0 + "PublishUserActivities" = 0 + "UploadUserActivities" = 0 + "AllowCrossDeviceClipboard" = 0 + } - $regPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" + $regPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" - try { - if (!(Test-Path $regPath)) { - New-Item -Path $regPath -Force | Out-Null - } - - $settings.GetEnumerator() | ForEach-Object { - Set-ItemProperty -Path $regPath -Name $_.Key -Type DWord -Value $_.Value -ErrorAction Stop - } - - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + try { + if (!(Test-Path $regPath)) { + New-Item -Path $regPath -Force | Out-Null } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + + $settings.GetEnumerator() | ForEach-Object { + Set-ItemProperty -Path $regPath -Name $_.Key -Type DWord -Value $_.Value -ErrorAction Stop } + + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableActivityHistory + DisableActivityHistory - # Disable clipboard history - Function DisableClipboardHistory { - Write-Host "Disabling clipboard history..." -NoNewline + # Disable clipboard history + Function DisableClipboardHistory { + Write-Host "Disabling clipboard history..." -NoNewline - $Clipboardreg1 = "HKCU:\Software\Microsoft\Clipboard" + $Clipboardreg1 = "HKCU:\Software\Microsoft\Clipboard" - if (-not (Test-Path $Clipboardreg1)) { - New-Item -Path $Clipboardreg1 -Force *>$null - } + if (-not (Test-Path $Clipboardreg1)) { + New-Item -Path $Clipboardreg1 -Force *>$null + } - $Clipboardreg2 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" + $Clipboardreg2 = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" - if (-not (Test-Path $Clipboardreg2)) { - New-Item -Path $Clipboardreg2 -Force *>$null - } + if (-not (Test-Path $Clipboardreg2)) { + New-Item -Path $Clipboardreg2 -Force *>$null + } - try { - Set-ItemProperty -Path $Clipboardreg1 -Name "EnableClipboardHistory" -Value 0 - Set-ItemProperty -Path $Clipboardreg2 -Name "AllowClipboardHistory" -Value 0 -Type DWord -Force - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + try { + Set-ItemProperty -Path $Clipboardreg1 -Name "EnableClipboardHistory" -Value 0 + Set-ItemProperty -Path $Clipboardreg2 -Name "AllowClipboardHistory" -Value 0 -Type DWord -Force + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableClipboardHistory + DisableClipboardHistory - # Disable diagnostic log collection - Function DisableDiagnosticLogCollection { - Write-Host "Disabling Diagnostic Log Collection..." -NoNewline + # Disable diagnostic log collection + Function DisableDiagnosticLogCollection { + Write-Host "Disabling Diagnostic Log Collection..." -NoNewline - $diagpath = "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\DataCollection" + $diagpath = "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\DataCollection" - if (-not (Test-Path $diagpath)) { - New-Item -Path $diagpath -Force *>$null - } + if (-not (Test-Path $diagpath)) { + New-Item -Path $diagpath -Force *>$null + } - try { - Set-ItemProperty -Path $diagpath -Name "LimitDiagnosticLogCollection" -Value 1 #Disable diagnostic log collection - Set-ItemProperty -Path $diagpath -Name "DisableOneSettingsDownloads" -Value 1 #Disable downloading of OneSettings configuration settings - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + try { + Set-ItemProperty -Path $diagpath -Name "LimitDiagnosticLogCollection" -Value 1 #Disable diagnostic log collection + Set-ItemProperty -Path $diagpath -Name "DisableOneSettingsDownloads" -Value 1 #Disable downloading of OneSettings configuration settings + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + } - DisableDiagnosticLogCollection + DisableDiagnosticLogCollection - # Disable User Steps Recorder - Function DisableUserStepsRecorder { - Write-Host "Disabling User Steps Recorder..." -NoNewline + # Disable User Steps Recorder + Function DisableUserStepsRecorder { + Write-Host "Disabling User Steps Recorder..." -NoNewline - $stepspath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat" + $stepspath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppCompat" - if (-not (Test-Path $stepspath)) { - New-Item -Path $stepspath -Force *>$null - } + if (-not (Test-Path $stepspath)) { + New-Item -Path $stepspath -Force *>$null + } - try { - Set-ItemProperty -Path $stepspath -Name "DisableUAR" -Value 1 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + try { + Set-ItemProperty -Path $stepspath -Name "DisableUAR" -Value 1 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableUserStepsRecorder + DisableUserStepsRecorder - # Disable Hardware Keyboard Text Suggestions - Function DisableHardwareKeyboardTextSuggestions { - Write-Host "Turning off text suggestions for hardware keyboard..." -NoNewline + # Disable Hardware Keyboard Text Suggestions + Function DisableHardwareKeyboardTextSuggestions { + Write-Host "Turning off text suggestions for hardware keyboard..." -NoNewline - $keyboardtext = "HKCU:\Software\Microsoft\Input\Settings" + $keyboardtext = "HKCU:\Software\Microsoft\Input\Settings" - if (-not (Test-Path $keyboardtext)) { - New-Item -Path $keyboardtext -Force *>$null - } + if (-not (Test-Path $keyboardtext)) { + New-Item -Path $keyboardtext -Force *>$null + } - try { - Set-ItemProperty -Path $keyboardtext -Name "EnableHwkbTextPrediction" -Value 0 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + try { + Set-ItemProperty -Path $keyboardtext -Name "EnableHwkbTextPrediction" -Value 0 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableHardwareKeyboardTextSuggestions + DisableHardwareKeyboardTextSuggestions - # Disable App Launch Tracking - Function DisableAppLaunchTracking { - Write-Host "Disabling App Launch Tracking..." -NoNewline + # Disable App Launch Tracking + Function DisableAppLaunchTracking { + Write-Host "Disabling App Launch Tracking..." -NoNewline - $applaunchtr = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" + $applaunchtr = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" - if (-not (Test-Path $applaunchtr)) { - New-Item -Path $applaunchtr -Force *>$null - } + if (-not (Test-Path $applaunchtr)) { + New-Item -Path $applaunchtr -Force *>$null + } - try { - Set-ItemProperty -Path $applaunchtr -Name "Start_TrackProgs" -Value 0 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + try { + Set-ItemProperty -Path $applaunchtr -Name "Start_TrackProgs" -Value 0 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableAppLaunchTracking + DisableAppLaunchTracking - # Disable setting 'Let websites provide locally relevant content by accessing my language list' - Function DisableWebLangList { - Write-Host "Disabling Website Access to Language List..." -NoNewline - try { - Set-ItemProperty -Path "HKCU:\Control Panel\International\User Profile" -Name "HttpAcceptLanguageOptOut" -Type DWord -Value 1 - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + # Disable setting 'Let websites provide locally relevant content by accessing my language list' + Function DisableWebLangList { + Write-Host "Disabling Website Access to Language List..." -NoNewline + try { + Set-ItemProperty -Path "HKCU:\Control Panel\International\User Profile" -Name "HttpAcceptLanguageOptOut" -Type DWord -Value 1 + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - DisableWebLangList + DisableWebLangList - # Stop and disable Connected User Experiences and Telemetry (previously named Diagnostics Tracking Service) - Function DisableDiagTrack { - Write-Host "Stopping and Disabling Connected User Experiences and Telemetry Service..." -NoNewline + # Stop and disable Connected User Experiences and Telemetry (previously named Diagnostics Tracking Service) + Function DisableDiagTrack { + Write-Host "Stopping and Disabling Connected User Experiences and Telemetry Service..." -NoNewline - try { - $diagservice = Get-Service "DiagTrack" -ErrorAction Stop + try { + $diagservice = Get-Service "DiagTrack" -ErrorAction Stop - if ($diagservice.Status -eq 'Running') { - Stop-Service "DiagTrack" -Force -ErrorAction Stop - } + if ($diagservice.Status -eq 'Running') { + Stop-Service "DiagTrack" -Force -ErrorAction Stop + } - Set-Service "DiagTrack" -StartupType Disabled -ErrorAction Stop + Set-Service "DiagTrack" -StartupType Disabled -ErrorAction Stop - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableDiagTrack + DisableDiagTrack - # Disable Advertising ID - Function DisableAdvertisingID { - Write-Host "Disabling Advertising ID..." -NoNewline - try { - 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 - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable Advertising ID + Function DisableAdvertisingID { + Write-Host "Disabling Advertising ID..." -NoNewline + try { + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo" | Out-Null } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AdvertisingInfo" -Name "DisabledByGroupPolicy" -Type DWord -Value 1 + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - DisableAdvertisingID + DisableAdvertisingID - # Disable Wi-Fi Sense - Function DisableWiFiSense { - Write-Host "Disabling Wi-Fi Sense..." -NoNewline + # Disable Wi-Fi Sense + Function DisableWiFiSense { + Write-Host "Disabling Wi-Fi Sense..." -NoNewline - try { - $paths = @( - "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting", - "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots", - "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" - ) + try { + $paths = @( + "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting", + "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots", + "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" + ) - foreach ($path in $paths) { - if (!(Test-Path $path)) { - New-Item -Path $path -Force | Out-Null - } + foreach ($path in $paths) { + if (!(Test-Path $path)) { + New-Item -Path $path -Force | Out-Null } + } - Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" -Name "Value" -Type DWord -Value 0 -ErrorAction Stop - Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots" -Name "Value" -Type DWord -Value 0 -ErrorAction Stop - Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" -Name "AutoConnectAllowedOEM" -Type DWord -Value 0 -ErrorAction Stop - Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" -Name "WiFISenseAllowed" -Type DWord -Value 0 -ErrorAction Stop + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowWiFiHotSpotReporting" -Name "Value" -Type DWord -Value 0 -ErrorAction Stop + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\PolicyManager\default\WiFi\AllowAutoConnectToWiFiSenseHotspots" -Name "Value" -Type DWord -Value 0 -ErrorAction Stop + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" -Name "AutoConnectAllowedOEM" -Type DWord -Value 0 -ErrorAction Stop + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\WcmSvc\wifinetworkmanager\config" -Name "WiFISenseAllowed" -Type DWord -Value 0 -ErrorAction Stop - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableWiFiSense + DisableWiFiSense - # Disable Application suggestions and automatic installation - Function DisableAppSuggestions { - Write-Host "Disabling Application Suggestions..." -NoNewline - - try { - $DisableAppSuggestions = @("ContentDeliveryAllowed", "OemPreInstalledAppsEnabled", "PreInstalledAppsEnabled", "PreInstalledAppsEverEnabled", "SilentInstalledAppsEnabled", "SubscribedContent-310093Enabled", - "SubscribedContent-314559Enabled", "SubscribedContent-338387Enabled", "SubscribedContent-338388Enabled", "SubscribedContent-338389Enabled", "SubscribedContent-338393Enabled", "SubscribedContent-353694Enabled", - "SubscribedContent-353696Enabled", "SubscribedContent-353698Enabled", "SystemPaneSuggestionsEnabled") + # Disable Application suggestions and automatic installation + Function DisableAppSuggestions { + Write-Host "Disabling Application Suggestions..." -NoNewline - foreach ($property in $DisableAppSuggestions) { - Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name $property -Type DWord -Value 0 -ErrorAction Stop - } - - If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement")) { - New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement" -Force | Out-Null - } - Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement" -Name "ScoobeSystemSettingEnabled" -Type DWord -Value 0 -ErrorAction Stop + try { + $DisableAppSuggestions = @("ContentDeliveryAllowed", "OemPreInstalledAppsEnabled", "PreInstalledAppsEnabled", "PreInstalledAppsEverEnabled", "SilentInstalledAppsEnabled", "SubscribedContent-310093Enabled", + "SubscribedContent-314559Enabled", "SubscribedContent-338387Enabled", "SubscribedContent-338388Enabled", "SubscribedContent-338389Enabled", "SubscribedContent-338393Enabled", "SubscribedContent-353694Enabled", + "SubscribedContent-353696Enabled", "SubscribedContent-353698Enabled", "SystemPaneSuggestionsEnabled") - 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 -ErrorAction Stop + foreach ($property in $DisableAppSuggestions) { + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\ContentDeliveryManager" -Name $property -Type DWord -Value 0 -ErrorAction Stop + } - 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] -ErrorAction Stop - Stop-Process -Name "ShellExperienceHost" -Force -ErrorAction SilentlyContinue - } + If (!(Test-Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement")) { + New-Item -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement" -Force | Out-Null + } + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\UserProfileEngagement" -Name "ScoobeSystemSettingEnabled" -Type DWord -Value 0 -ErrorAction Stop - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsInkWorkspace")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsInkWorkspace" -Force | Out-Null } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\WindowsInkWorkspace" -Name "AllowSuggestedAppsInWindowsInkWorkspace" -Type DWord -Value 0 -ErrorAction Stop + + 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] -ErrorAction Stop + Stop-Process -Name "ShellExperienceHost" -Force -ErrorAction SilentlyContinue } + + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + } - DisableAppSuggestions + DisableAppSuggestions - # Disable UWP apps background access - ie. if UWP apps can download data or update themselves when they aren't used - Function DisableUWPBackgroundApps { - Write-Host "Disabling UWP Apps Background Access..." -NoNewline + # Disable UWP apps background access - ie. if UWP apps can download data or update themselves when they aren't used + Function DisableUWPBackgroundApps { + Write-Host "Disabling UWP Apps Background Access..." -NoNewline - try { - If ([System.Environment]::OSVersion.Version.Build -ge 17763) { - 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 "LetAppsRunInBackground" -Type DWord -Value 2 -ErrorAction Stop + try { + If ([System.Environment]::OSVersion.Version.Build -ge 17763) { + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Force | Out-Null } - Else { - $backgroundApps = Get-ChildItem -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications" -Exclude "Microsoft.Windows.Cortana*", "Microsoft.Windows.ShellExperienceHost*" + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name "LetAppsRunInBackground" -Type DWord -Value 2 -ErrorAction Stop + } + Else { + $backgroundApps = Get-ChildItem -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\BackgroundAccessApplications" -Exclude "Microsoft.Windows.Cortana*", "Microsoft.Windows.ShellExperienceHost*" - foreach ($app in $backgroundApps) { - Set-ItemProperty -Path $app.PsPath -Name "Disabled" -Type DWord -Value 1 -ErrorAction Stop - Set-ItemProperty -Path $app.PsPath -Name "DisabledByUser" -Type DWord -Value 1 -ErrorAction Stop - } + foreach ($app in $backgroundApps) { + Set-ItemProperty -Path $app.PsPath -Name "Disabled" -Type DWord -Value 1 -ErrorAction Stop + Set-ItemProperty -Path $app.PsPath -Name "DisabledByUser" -Type DWord -Value 1 -ErrorAction Stop } - - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + } - DisableUWPBackgroundApps + DisableUWPBackgroundApps - # Disable access to voice activation from UWP apps - Function DisableUWPVoiceActivation { - Write-Host "Disabling Access to Voice Activation from UWP Apps..." -NoNewline - try { - 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 "LetAppsActivateWithVoice" -Type DWord -Value 2 - Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name "LetAppsActivateWithVoiceAboveLock" -Type DWord -Value 2 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable access to voice activation from UWP apps + Function DisableUWPVoiceActivation { + Write-Host "Disabling Access to Voice Activation from UWP Apps..." -NoNewline + try { + 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 "LetAppsActivateWithVoice" -Type DWord -Value 2 + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name "LetAppsActivateWithVoiceAboveLock" -Type DWord -Value 2 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } - - DisableUWPVoiceActivation - - # Disable access to notifications from UWP apps - Function DisableUWPNotifications { - Write-Host "Disabling Access to Notifications from UWP Apps..." -NoNewline - try { - 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 "LetAppsAccessNotifications" -Type DWord -Value 2 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableUWPNotifications + DisableUWPVoiceActivation - # Disable access to account info from UWP apps - Function DisableUWPAccountInfo { - Write-Host "Disabling Access to account Info from UWP Apps..." -NoNewline - try { - 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 "LetAppsAccessAccountInfo" -Type DWord -Value 2 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable access to notifications from UWP apps + Function DisableUWPNotifications { + Write-Host "Disabling Access to Notifications from UWP Apps..." -NoNewline + try { + 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 "LetAppsAccessNotifications" -Type DWord -Value 2 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableUWPAccountInfo + DisableUWPNotifications - # Disable access to contacts from UWP apps - Function DisableUWPContacts { - Write-Host "Disabling Access to Contacts from UWP Apps..." -NoNewline - try { - 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 "LetAppsAccessContacts" -Type DWord -Value 2 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable access to account info from UWP apps + Function DisableUWPAccountInfo { + Write-Host "Disabling Access to account Info from UWP Apps..." -NoNewline + try { + 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 "LetAppsAccessAccountInfo" -Type DWord -Value 2 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableUWPContacts + DisableUWPAccountInfo - # Disable access to calendar from UWP apps - Function DisableUWPCalendar { - Write-Host "Disabling Access to Calendar from UWP Apps..." -NoNewline - try { - 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 "LetAppsAccessCalendar" -Type DWord -Value 2 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable access to contacts from UWP apps + Function DisableUWPContacts { + Write-Host "Disabling Access to Contacts from UWP Apps..." -NoNewline + try { + 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 "LetAppsAccessContacts" -Type DWord -Value 2 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + } - DisableUWPCalendar + DisableUWPContacts - # Disable access to phone calls from UWP apps - Function DisableUWPPhoneCalls { - Write-Host "Disabling Access to Phone Calls from UWP Apps..." -NoNewline - try { - 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 "LetAppsAccessPhone" -Type DWord -Value 2 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable access to calendar from UWP apps + Function DisableUWPCalendar { + Write-Host "Disabling Access to Calendar from UWP Apps..." -NoNewline + try { + 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 "LetAppsAccessCalendar" -Type DWord -Value 2 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + } - DisableUWPPhoneCalls + DisableUWPCalendar - # Disable access to call history from UWP apps - Function DisableUWPCallHistory { - Write-Host "Disabling Access to Call History from UWP Apps..." -NoNewline - try { - 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 "LetAppsAccessCallHistory" -Type DWord -Value 2 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable access to phone calls from UWP apps + Function DisableUWPPhoneCalls { + Write-Host "Disabling Access to Phone Calls from UWP Apps..." -NoNewline + try { + 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 "LetAppsAccessPhone" -Type DWord -Value 2 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + } - DisableUWPCallHistory + DisableUWPPhoneCalls - # Disable access to email from UWP apps - Function DisableUWPEmail { - Write-Host "Disabling Access to Email from UWP Apps..." -NoNewline - try { - 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 "LetAppsAccessEmail" -Type DWord -Value 2 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable access to call history from UWP apps + Function DisableUWPCallHistory { + Write-Host "Disabling Access to Call History from UWP Apps..." -NoNewline + try { + 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 "LetAppsAccessCallHistory" -Type DWord -Value 2 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableUWPEmail + DisableUWPCallHistory - # Disable access to tasks from UWP apps - Function DisableUWPTasks { - Write-Host "Disabling Access to Tasks from UWP Apps..." -NoNewline - try { - 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 "LetAppsAccessTasks" -Type DWord -Value 2 - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable access to email from UWP apps + Function DisableUWPEmail { + Write-Host "Disabling Access to Email from UWP Apps..." -NoNewline + try { + 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 "LetAppsAccessEmail" -Type DWord -Value 2 Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + } - DisableUWPTasks + DisableUWPEmail - # Disable access to messaging (SMS, MMS) from UWP apps - Function DisableUWPMessaging { - Write-Host "Disabling Access to Messaging from UWP Apps..." -NoNewline - try { - 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 "LetAppsAccessMessaging" -Type DWord -Value 2 - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable access to tasks from UWP apps + Function DisableUWPTasks { + Write-Host "Disabling Access to Tasks from UWP Apps..." -NoNewline + try { + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Force | Out-Null } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name "LetAppsAccessTasks" -Type DWord -Value 2 } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - DisableUWPMessaging + DisableUWPTasks - # Disable access to radios (e.g. Bluetooth) from UWP apps - Function DisableUWPRadios { - Write-Host "Disabling Access to Radios from UWP Apps..." -NoNewline - try { - 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 "LetAppsAccessRadios" -Type DWord -Value 2 - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable access to messaging (SMS, MMS) from UWP apps + Function DisableUWPMessaging { + Write-Host "Disabling Access to Messaging from UWP Apps..." -NoNewline + try { + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Force | Out-Null } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name "LetAppsAccessMessaging" -Type DWord -Value 2 + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - DisableUWPRadios + DisableUWPMessaging - # Disable access to other devices (unpaired, beacons, TVs etc.) from UWP apps - Function DisableUWPOtherDevices { - Write-Host "Disabling Access to Other Devices from UWP Apps..." -NoNewline - try { - 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 "LetAppsSyncWithDevices" -Type DWord -Value 2 - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable access to radios (e.g. Bluetooth) from UWP apps + Function DisableUWPRadios { + Write-Host "Disabling Access to Radios from UWP Apps..." -NoNewline + try { + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Force | Out-Null } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name "LetAppsAccessRadios" -Type DWord -Value 2 + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - DisableUWPOtherDevices + DisableUWPRadios - # Disable access to diagnostic information from UWP apps - Function DisableUWPDiagInfo { - Write-Host "Disabling Access to Diagnostic Information from UWP Apps..." -NoNewline - try { - 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 "LetAppsGetDiagnosticInfo" -Type DWord -Value 2 - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable access to other devices (unpaired, beacons, TVs etc.) from UWP apps + Function DisableUWPOtherDevices { + Write-Host "Disabling Access to Other Devices from UWP Apps..." -NoNewline + try { + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Force | Out-Null } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\AppPrivacy" -Name "LetAppsSyncWithDevices" -Type DWord -Value 2 } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - DisableUWPDiagInfo + DisableUWPOtherDevices - # Disable access to libraries and file system from UWP apps - Function DisableUWPFileSystem { - Write-Host "Disabling Access to Libraries and File System from UWP Apps..." -NoNewline - - $paths = @( - "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\documentsLibrary", - "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\picturesLibrary", - "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\videosLibrary", - "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\broadFileSystemAccess", - "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\userAccountInformation", - "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\appDiagnostics", - "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location", - "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\contacts", - "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\email", - "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\userDataTasks", - "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\chat", - "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\userAccountInformation", - "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\appDiagnostics" - ) - - try { - foreach ($path in $paths) { - if (Test-Path $path) { - ## - } - else { - New-Item -Path $path -Force | Out-Null - Set-ItemProperty -Path $path -Name "Value" -Type String -Value "Deny" -ErrorAction Stop - } + # Disable access to diagnostic information from UWP apps + Function DisableUWPDiagInfo { + Write-Host "Disabling Access to Diagnostic Information from UWP Apps..." -NoNewline + try { + 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 "LetAppsGetDiagnosticInfo" -Type DWord -Value 2 + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + + DisableUWPDiagInfo + + # Disable access to libraries and file system from UWP apps + Function DisableUWPFileSystem { + Write-Host "Disabling Access to Libraries and File System from UWP Apps..." -NoNewline + + $paths = @( + "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\documentsLibrary", + "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\picturesLibrary", + "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\videosLibrary", + "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\broadFileSystemAccess", + "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\userAccountInformation", + "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\appDiagnostics", + "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\location", + "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\contacts", + "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\email", + "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\userDataTasks", + "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\chat", + "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\userAccountInformation", + "HKCU:\Software\Microsoft\Windows\CurrentVersion\CapabilityAccessManager\ConsentStore\appDiagnostics" + ) + + try { + foreach ($path in $paths) { + if (Test-Path $path) { + ## + } + else { + New-Item -Path $path -Force | Out-Null + Set-ItemProperty -Path $path -Name "Value" -Type String -Value "Deny" -ErrorAction Stop } - Write-Host "[DONE]" -ForegroundColor Green - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red } + Write-Host "[DONE]" -ForegroundColor Green } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red + } + } - DisableUWPFileSystem + DisableUWPFileSystem - # Disable UWP apps swap file - # This disables creation and use of swapfile.sys and frees 256 MB of disk space. Swapfile.sys is used only by UWP apps. The tweak has no effect on the real swap in pagefile.sys. - Function DisableUWPSwapFile { - Write-Host "Disabling UWP Apps Swap File..." -NoNewline + # Disable UWP apps swap file + # This disables creation and use of swapfile.sys and frees 256 MB of disk space. Swapfile.sys is used only by UWP apps. The tweak has no effect on the real swap in pagefile.sys. + Function DisableUWPSwapFile { + Write-Host "Disabling UWP Apps Swap File..." -NoNewline - try { - Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" -Name "SwapfileControl" -Type Dword -Value 0 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + try { + Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management" -Name "SwapfileControl" -Type Dword -Value 0 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableUWPSwapFile + DisableUWPSwapFile - # Disable automatic Maps updates - Function DisableMapUpdates { - Write-Host "Disabling Automatic Maps Updates..." -NoNewline - try { - If (!(Test-Path "HKLM:\SYSTEM\Maps")) { - New-Item -Path "HKLM:\SYSTEM\Maps" -Force | Out-Null - } - Set-ItemProperty -Path "HKLM:\SYSTEM\Maps" -Name "AutoUpdateEnabled" -Type DWord -Value 0 -ErrorAction Stop - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # Disable automatic Maps updates + Function DisableMapUpdates { + Write-Host "Disabling Automatic Maps Updates..." -NoNewline + try { + If (!(Test-Path "HKLM:\SYSTEM\Maps")) { + New-Item -Path "HKLM:\SYSTEM\Maps" -Force | Out-Null } + Set-ItemProperty -Path "HKLM:\SYSTEM\Maps" -Name "AutoUpdateEnabled" -Type DWord -Value 0 -ErrorAction Stop + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - DisableMapUpdates + DisableMapUpdates - # 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-Host "Disabling Windows Update Automatic Restart..." -NoNewline - try { - 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" - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + # 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-Host "Disabling Windows Update Automatic Restart..." -NoNewline + try { + 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 } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\MusNotification.exe" -Name "Debugger" -Type String -Value "cmd.exe" + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - DisableUpdateRestart + DisableUpdateRestart - # Disable Windows Update automatic downloads - Function DisableUpdateAutoDownload { - Write-Host "Disabling Windows Update Automatic Downloads..." -NoNewline - try { - 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 "NoAutoUpdate" -Type DWord -Value 1 -ErrorAction Stop + # Disable Windows Update automatic downloads + Function DisableUpdateAutoDownload { + Write-Host "Disabling Windows Update Automatic Downloads..." -NoNewline + try { + 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 "NoAutoUpdate" -Type DWord -Value 1 -ErrorAction Stop - If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization")) { - New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" -Force | Out-Null - } - Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" -Name "DODownloadMode" -Type DWord -Value 0 -ErrorAction Stop + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" -Force | Out-Null + } + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\DeliveryOptimization" -Name "DODownloadMode" -Type DWord -Value 0 -ErrorAction Stop - If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config")) { - New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Force | Out-Null - } + If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config")) { + New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Force | Out-Null + } - Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -Type DWord -Value 0 -ErrorAction Stop + Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -Type DWord -Value 0 -ErrorAction Stop - If (!(Test-Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\DeliveryOptimization")) { - New-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\DeliveryOptimization" -Force | Out-Null - } + If (!(Test-Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\DeliveryOptimization")) { + New-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\DeliveryOptimization" -Force | Out-Null + } - Set-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\DeliveryOptimization" -Name "DODownloadMode" -Type DWord -Value 0 -ErrorAction Stop + Set-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows\DeliveryOptimization" -Name "DODownloadMode" -Type DWord -Value 0 -ErrorAction Stop - New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS | Out-Null - $currentSID = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value - $userKey = "HKU:\$currentSID" - If (!(Test-Path "$userKey\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization")) { - New-Item -Path "$userKey\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization" -Force | Out-Null - } + New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS | Out-Null + $currentSID = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value + $userKey = "HKU:\$currentSID" + If (!(Test-Path "$userKey\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization")) { + New-Item -Path "$userKey\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization" -Force | Out-Null + } - Set-ItemProperty -Path "$userKey\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization" -Name "SystemSettingsDownloadMode" -Type DWord -Value 0 -ErrorAction Stop + Set-ItemProperty -Path "$userKey\Software\Microsoft\Windows\CurrentVersion\DeliveryOptimization" -Name "SystemSettingsDownloadMode" -Type DWord -Value 0 -ErrorAction Stop - # Disable updates to the speech recognition and speech synthesis modules - If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Speech")) { - New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Speech" -Force | Out-Null - } - Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Speech" -Name "AllowSpeechModelUpdate" -Type DWord -Value 0 -ErrorAction Stop - - If (!(Test-Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Speech")) { - New-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Speech" -Force | Out-Null - } - Set-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Speech" -Name "AllowSpeechModelUpdate" -Type DWord -Value 0 -ErrorAction Stop + # Disable updates to the speech recognition and speech synthesis modules + If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Speech")) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Speech" -Force | Out-Null } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Speech" -Name "AllowSpeechModelUpdate" -Type DWord -Value 0 -ErrorAction Stop + + If (!(Test-Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Speech")) { + New-Item -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Speech" -Force | Out-Null } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Set-ItemProperty -Path "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Speech" -Name "AllowSpeechModelUpdate" -Type DWord -Value 0 -ErrorAction Stop + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - DisableUpdateAutoDownload + DisableUpdateAutoDownload - # Enable Task Scheduler History - Function EnableTaskSchedulerHistory { - Write-Host "Enabling Task Scheduler History..." -NoNewline - wevtutil sl Microsoft-Windows-TaskScheduler/Operational /e:true - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } + # Enable Task Scheduler History + Function EnableTaskSchedulerHistory { + Write-Host "Enabling Task Scheduler History..." -NoNewline + wevtutil sl Microsoft-Windows-TaskScheduler/Operational /e:true + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - EnableTaskSchedulerHistory + EnableTaskSchedulerHistory - } - elseif ($response -eq 'n' -or $response -eq 'N') { - Write-Host "[Privacy Settings Cancelled]" -ForegroundColor Red -BackgroundColor Black - } - else { - Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." - PrivacySettings - } } + elseif ($response -eq 'n' -or $response -eq 'N') { + Write-Host "[Privacy Settings Cancelled]" -ForegroundColor Red -BackgroundColor Black + } + else { + Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." + PrivacySettings + } +} + +PrivacySettings + +########## +#endregion Privacy Settings +########## + +########## +#region Install Softwares +########## +Function GithubSoftwares { + Write-Host `n"---------Installing Softwares" -ForegroundColor Blue -BackgroundColor Gray + + Write-Host `n"Do you want to " -NoNewline + Write-Host "install applications that are written on github?" -ForegroundColor Yellow -NoNewline + Write-Host "(y/n): " -ForegroundColor Green -NoNewline + $response = Read-Host + if ($response -eq 'y' -or $response -eq 'Y') { - PrivacySettings - - ########## - #endregion Privacy Settings - ########## - - ########## - #region Install Softwares - ########## - Function GithubSoftwares { - Write-Host `n"---------Installing Softwares" -ForegroundColor Blue -BackgroundColor Gray - - Write-Host `n"Do you want to " -NoNewline - Write-Host "install applications that are written on github?" -ForegroundColor Yellow -NoNewline - Write-Host "(y/n): " -ForegroundColor Green -NoNewline - $response = Read-Host - if ($response -eq 'y' -or $response -eq 'Y') { - - Function installwinget { - # I now use asheroto's https://github.com/asheroto/winget-install repo to install winget - Write-Host `n"Installing/upgrading winget..." -NoNewline - # The winget install script will stay here as a backup - <# + Function installwinget { + # I now use asheroto's https://github.com/asheroto/winget-install repo to install winget + Write-Host `n"Installing/upgrading winget..." -NoNewline + # The winget install script will stay here as a backup + <# Function InstallOrUpdateWinget { Function Silent { $Global:ProgressPreference = 'SilentlyContinue' @@ -3234,1039 +3234,1050 @@ Function InstallOrUpdateWinget { InstallOrUpdateWinget #> - $job = Start-Job -ScriptBlock { - &([ScriptBlock]::Create((irm winget.pro))) -Force *>$null - } + $job = Start-Job -ScriptBlock { + &([ScriptBlock]::Create((irm winget.pro))) -Force *>$null + } - Wait-Job -Job $job | Out-Null + Wait-Job -Job $job | Out-Null - #create softwares task - $wtPath = Get-Command wt.exe | Select-Object -ExpandProperty Definition + #create softwares task + $wtPath = Get-Command wt.exe | Select-Object -ExpandProperty Definition - $psCommand = "powershell.exe -ExecutionPolicy Bypass -Command `"iwr 'https://raw.githubusercontent.com/caglaryalcin/after-format/main/resume.psm1' -UseBasicParsing | iex`"" - $wtCommand = "-w 0 new-tab $psCommand" - $action = New-ScheduledTaskAction -Execute $wtPath -Argument $wtCommand - $trigger = New-ScheduledTaskTrigger -AtLogon - $principal = New-ScheduledTaskPrincipal -GroupId "S-1-5-32-544" -RunLevel Highest - $taskname = "softwares" - $description = "temp task" - $settings = New-ScheduledTaskSettingsSet + $psCommand = "powershell.exe -ExecutionPolicy Bypass -Command `"iwr 'https://raw.githubusercontent.com/caglaryalcin/after-format/main/resume.psm1' -UseBasicParsing | iex`"" + $wtCommand = "-w 0 new-tab $psCommand" + $action = New-ScheduledTaskAction -Execute $wtPath -Argument $wtCommand + $trigger = New-ScheduledTaskTrigger -AtLogon + $principal = New-ScheduledTaskPrincipal -GroupId "S-1-5-32-544" -RunLevel Highest + $taskname = "softwares" + $description = "temp task" + $settings = New-ScheduledTaskSettingsSet - $task = Register-ScheduledTask -TaskName $taskname -Trigger $trigger -Action $action -Principal $principal -Settings $settings -Description $description - $task | Set-ScheduledTask *>$null + $task = Register-ScheduledTask -TaskName $taskname -Trigger $trigger -Action $action -Principal $principal -Settings $settings -Description $description + $task | Set-ScheduledTask *>$null - Start-Sleep 2 - Restart-Computer -Force - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Start-Sleep 2 + Restart-Computer -Force + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } + } - installwinget + installwinget - } + } - elseif ($response -eq 'n' -or $response -eq 'N') { - Write-Host "[Softwares written on Github will not be installed]" -ForegroundColor Red -BackgroundColor Black + elseif ($response -eq 'n' -or $response -eq 'N') { + Write-Host "[Softwares written on Github will not be installed]" -ForegroundColor Red -BackgroundColor Black - ########## - #region Remove Unused Apps/Softwares - ########## - Function UnusedApps { - Write-Host `n"---------Remove Unused Apps/Softwares" -ForegroundColor Blue -BackgroundColor Gray + ########## + #region Remove Unused Apps/Softwares + ########## + Function UnusedApps { + Write-Host `n"---------Remove Unused Apps/Softwares" -ForegroundColor Blue -BackgroundColor Gray - Write-Host `n"Do you want " -NoNewline - Write-Host "Uninstall Unused Apps & Softwares?" -ForegroundColor Yellow -NoNewline - Write-Host "(y/n): " -ForegroundColor Green -NoNewline - $response = Read-Host + Write-Host `n"Do you want " -NoNewline + Write-Host "Uninstall Unused Apps & Softwares?" -ForegroundColor Yellow -NoNewline + Write-Host "(y/n): " -ForegroundColor Green -NoNewline + $response = Read-Host - if ($response -eq 'y' -or $response -eq 'Y') { + if ($response -eq 'y' -or $response -eq 'Y') { - # Remove Apps - Function UninstallThirdPartyBloat { - Write-Host "Uninstalling Default Third Party Applications..." -NoNewline + # Remove Apps + Function UninstallThirdPartyBloat { + Write-Host "Uninstalling Default Third Party Applications..." -NoNewline - $UninstallAppxPackages = - "Microsoft.WindowsAlarms", #Alarm and clock app for Windows. - "Microsoft.549981C3F5F10", #Code likely represents a specific app or service, specifics unknown without context. - "Microsoft.WindowsFeedbackHub", #Platform for user feedback on Windows. - "Microsoft.Bing*", #Bing search engine related services and apps. - "Microsoft.Zune*", #Media software for music and videos, now discontinued. - "Microsoft.PowerAutomateDesktop", #Automation tool for desktop workflows. - "Microsoft.WindowsSoundRecorder", #Audio recording app for Windows. - "Microsoft.MicrosoftSolitaireCollection", #Solitaire game collection. - "Microsoft.GamingApp", #Likely related to Xbox or Windows gaming services. - "*microsoft.windowscomm**", #Likely refers to communication services in Windows, specifics unclear. - "MicrosoftCorporationII.QuickAssist", #Remote assistance app by Microsoft. - "Microsoft.Todos", #Task management app. - "Microsoft.SkypeApp", #Skype communication app for Windows. - "Microsoft.Microsoft3DViewer", #App for viewing 3D models. - "Microsoft.Wallet", #Digital wallet app, now discontinued. - "Microsoft.WebMediaExtensions", #Extensions for media formats in web browsers. - "MicrosoftWindows.Client.WebExperience", #Likely related to the web browsing experience in Windows, specifics unclear. - "Clipchamp.Clipchamp", #Video editing app. - "Microsoft.WindowsMaps", #Mapping and navigation app. - "Microsoft.Advertising.Xaml", #Advertising SDK for apps. - "Microsoft.MixedReality.Portal", #Mixed Reality portal app for immersive experiences. - "Microsoft.BingNews", #News aggregation app. - "Microsoft.GetHelp", #Support and troubleshooting app. - "Microsoft.Getstarted", #Introduction and tips app for Windows features. - "Microsoft.MicrosoftOfficeHub", #Central hub for Office apps and services. - "Microsoft.OneConnect", #Connectivity and cloud services app. - "Microsoft.People", #Contact management and social integration app. - "Microsoft.Xbox.TCUI", #Xbox text, chat, and user interface services. - "Microsoft.XboxApp", #Main app for Xbox social and gaming features. - "Microsoft.XboxGameOverlay", #In-game overlay for Xbox features and social interactions. - "Microsoft.XboxIdentityProvider", #Service for Xbox account authentication. - "Microsoft.XboxSpeechToTextOverlay" #Speech-to-text services for Xbox gaming. - - $installedApps = Get-AppxPackage -AllUsers + $UninstallAppxPackages = + "Microsoft.WindowsAlarms", #Alarm and clock app for Windows. + "Microsoft.549981C3F5F10", #Code likely represents a specific app or service, specifics unknown without context. + "Microsoft.WindowsFeedbackHub", #Platform for user feedback on Windows. + "Microsoft.Bing*", #Bing search engine related services and apps. + "Microsoft.Zune*", #Media software for music and videos, now discontinued. + "Microsoft.PowerAutomateDesktop", #Automation tool for desktop workflows. + "Microsoft.WindowsSoundRecorder", #Audio recording app for Windows. + "Microsoft.MicrosoftSolitaireCollection", #Solitaire game collection. + "Microsoft.GamingApp", #Likely related to Xbox or Windows gaming services. + "*microsoft.windowscomm**", #Likely refers to communication services in Windows, specifics unclear. + "MicrosoftCorporationII.QuickAssist", #Remote assistance app by Microsoft. + "Microsoft.Todos", #Task management app. + "Microsoft.SkypeApp", #Skype communication app for Windows. + "Microsoft.Microsoft3DViewer", #App for viewing 3D models. + "Microsoft.Wallet", #Digital wallet app, now discontinued. + "Microsoft.WebMediaExtensions", #Extensions for media formats in web browsers. + "MicrosoftWindows.Client.WebExperience", #Likely related to the web browsing experience in Windows, specifics unclear. + "Clipchamp.Clipchamp", #Video editing app. + "Microsoft.WindowsMaps", #Mapping and navigation app. + "Microsoft.Advertising.Xaml", #Advertising SDK for apps. + "Microsoft.MixedReality.Portal", #Mixed Reality portal app for immersive experiences. + "Microsoft.BingNews", #News aggregation app. + "Microsoft.GetHelp", #Support and troubleshooting app. + "Microsoft.Getstarted", #Introduction and tips app for Windows features. + "Microsoft.MicrosoftOfficeHub", #Central hub for Office apps and services. + "Microsoft.OneConnect", #Connectivity and cloud services app. + "Microsoft.People", #Contact management and social integration app. + "Microsoft.Xbox.TCUI", #Xbox text, chat, and user interface services. + "Microsoft.XboxApp", #Main app for Xbox social and gaming features. + "Microsoft.XboxGameOverlay", #In-game overlay for Xbox features and social interactions. + "Microsoft.XboxIdentityProvider", #Service for Xbox account authentication. + "Microsoft.XboxSpeechToTextOverlay" #Speech-to-text services for Xbox gaming. + + $installedApps = Get-AppxPackage -AllUsers - Silent #silently + Silent #silently - foreach ($package in $UninstallAppxPackages) { - $app = $installedApps | Where-Object { $_.Name -like $package } - if ($null -ne $app) { - try { - $app | Remove-AppxPackage -ErrorAction Stop - } - catch { - Write-Host "[WARNING] $($_.Exception.Message)" -ForegroundColor Red -BackgroundColor Black - } - } - } - - # Uninstall Microsoft Teams Outlook Add-in - $TeamsAddinGUID = '{A7AB73A3-CB10-4AA5-9D38-6AEFFBDE4C91}' - $teamsregpath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$TeamsAddinGUID" - if (Test-Path $teamsregpath) { + foreach ($package in $UninstallAppxPackages) { + $app = $installedApps | Where-Object { $_.Name -like $package } + if ($null -ne $app) { try { - Start-Process msiexec.exe -ArgumentList "/x $TeamsAddinGUID /qn /norestart" -NoNewWindow -Wait + $app | Remove-AppxPackage -ErrorAction Stop } catch { Write-Host "[WARNING] $($_.Exception.Message)" -ForegroundColor Red -BackgroundColor Black } } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } - UninstallThirdPartyBloat - - # Uninstall Windows Media Player - Function UninstallMediaPlayer { - Write-Host `n"Uninstalling Windows Media Player..." -NoNewline + # Uninstall Microsoft Teams Outlook Add-in + $TeamsAddinGUID = '{A7AB73A3-CB10-4AA5-9D38-6AEFFBDE4C91}' + $teamsregpath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$TeamsAddinGUID" + if (Test-Path $teamsregpath) { try { - Silent #silently - Get-WindowsOptionalFeature -Online | Where-Object { $_.FeatureName -eq "WindowsMediaPlayer" } | Disable-WindowsOptionalFeature -Online -NoRestart -WarningAction SilentlyContinue | Out-Null - Get-WindowsCapability -Online | Where-Object { $_.Name -like "Media.WindowsMediaPlayer*" } | Remove-WindowsCapability -Online | Out-Null + Start-Process msiexec.exe -ArgumentList "/x $TeamsAddinGUID /qn /norestart" -NoNewWindow -Wait } catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + Write-Host "[WARNING] $($_.Exception.Message)" -ForegroundColor Red -BackgroundColor Black } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + + UninstallThirdPartyBloat + + # Uninstall Windows Media Player + Function UninstallMediaPlayer { + Write-Host `n"Uninstalling Windows Media Player..." -NoNewline + try { + Silent #silently + Get-WindowsOptionalFeature -Online | Where-Object { $_.FeatureName -eq "WindowsMediaPlayer" } | Disable-WindowsOptionalFeature -Online -NoRestart -WarningAction SilentlyContinue | Out-Null + Get-WindowsCapability -Online | Where-Object { $_.Name -like "Media.WindowsMediaPlayer*" } | Remove-WindowsCapability -Online | Out-Null + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - UninstallMediaPlayer + UninstallMediaPlayer - # Uninstall Work Folders Client - Not applicable to Server - Function UninstallWorkFolders { - Write-Host "Uninstalling Work Folders Client..." -NoNewline - try { - Silent #silently - Get-WindowsOptionalFeature -Online | Where-Object { $_.FeatureName -eq "WorkFolders-Client" } | Disable-WindowsOptionalFeature -Online -NoRestart -WarningAction SilentlyContinue | Out-Null - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + # Uninstall Work Folders Client - Not applicable to Server + Function UninstallWorkFolders { + Write-Host "Uninstalling Work Folders Client..." -NoNewline + try { + Silent #silently + Get-WindowsOptionalFeature -Online | Where-Object { $_.FeatureName -eq "WorkFolders-Client" } | Disable-WindowsOptionalFeature -Online -NoRestart -WarningAction SilentlyContinue | Out-Null + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - UninstallWorkFolders + UninstallWorkFolders - # Uninstall Microsoft XPS Document Writer - Function UninstallXPSPrinter { - Write-Host "Uninstalling Microsoft XPS Document Writer..." -NoNewline - try { - Remove-Printer -Name "Microsoft XPS Document Writer" -ErrorAction SilentlyContinue - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + # Uninstall Microsoft XPS Document Writer + Function UninstallXPSPrinter { + Write-Host "Uninstalling Microsoft XPS Document Writer..." -NoNewline + try { + Remove-Printer -Name "Microsoft XPS Document Writer" -ErrorAction SilentlyContinue + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - UninstallXPSPrinter + UninstallXPSPrinter - # Remove Default Fax Printer - Function RemoveFaxPrinter { - Write-Host "Removing Default Fax Printer..." -NoNewline - try { - Remove-Printer -Name "Fax" -ErrorAction SilentlyContinue - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + # Remove Default Fax Printer + Function RemoveFaxPrinter { + Write-Host "Removing Default Fax Printer..." -NoNewline + try { + Remove-Printer -Name "Fax" -ErrorAction SilentlyContinue + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - RemoveFaxPrinter + RemoveFaxPrinter - # Uninstall Windows Fax and Scan Services - Not applicable to Server - Function UninstallFaxAndScan { - Write-Host "Uninstalling Windows Fax and Scan Services..." -NoNewline - try { - Silent #silently - Get-WindowsOptionalFeature -Online | Where-Object { $_.FeatureName -eq "FaxServicesClientPackage" } | Disable-WindowsOptionalFeature -Online -NoRestart -WarningAction SilentlyContinue | Out-Null - Get-WindowsCapability -Online | Where-Object { $_.Name -like "Print.Fax.Scan*" } | Remove-WindowsCapability -Online | Out-Null - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + # Uninstall Windows Fax and Scan Services - Not applicable to Server + Function UninstallFaxAndScan { + Write-Host "Uninstalling Windows Fax and Scan Services..." -NoNewline + try { + Silent #silently + Get-WindowsOptionalFeature -Online | Where-Object { $_.FeatureName -eq "FaxServicesClientPackage" } | Disable-WindowsOptionalFeature -Online -NoRestart -WarningAction SilentlyContinue | Out-Null + Get-WindowsCapability -Online | Where-Object { $_.Name -like "Print.Fax.Scan*" } | Remove-WindowsCapability -Online | Out-Null } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - UninstallFaxAndScan - - # Delete some folders from This PC - Function UnpinExplorer { - Write-Host "Deleting 3D Folders, Pictures, Videos, Music from This PC..." -NoNewline - $basePath = "HKLM:\SOFTWARE" - $wow6432Node = "Wow6432Node\" - $explorerPath = "Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\" - $quickAccessPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HomeFolderMSGraph\NameSpace\DelegateFolders\{3936E9E4-D92C-4EEE-A85A-BC16D5EA0819}" - $homePath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace_36354489\{f874310e-b6b7-47dc-bc84-b9e6b38f5903}" - $homePath2 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{f874310e-b6b7-47dc-bc84-b9e6b38f5903}" - $namespaces = @{ - "3DFolders" = "{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" - "Videos" = "{A0953C92-50DC-43bf-BE83-3742FED03C9C}", "{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}" - "Pictures" = "{3ADD1653-EB32-4cb0-BBD7-DFA0ABB5ACCA}", "{24ad3ad4-a569-4530-98e1-ab02f9417aa8}" - } + UninstallFaxAndScan + + # Delete some folders from This PC + Function UnpinExplorer { + Write-Host "Deleting 3D Folders, Pictures, Videos, Music from This PC..." -NoNewline + $basePath = "HKLM:\SOFTWARE" + $wow6432Node = "Wow6432Node\" + $explorerPath = "Microsoft\Windows\CurrentVersion\Explorer\MyComputer\NameSpace\" + $quickAccessPath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\HomeFolderMSGraph\NameSpace\DelegateFolders\{3936E9E4-D92C-4EEE-A85A-BC16D5EA0819}" + $homePath = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace_36354489\{f874310e-b6b7-47dc-bc84-b9e6b38f5903}" + $homePath2 = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Desktop\NameSpace\{f874310e-b6b7-47dc-bc84-b9e6b38f5903}" + $namespaces = @{ + "3DFolders" = "{0DB7E03F-FC29-4DC6-9020-FF41B59E513A}" + "Videos" = "{A0953C92-50DC-43bf-BE83-3742FED03C9C}", "{f86fa3ab-70d2-4fc7-9c99-fcbf05467f3a}" + "Pictures" = "{3ADD1653-EB32-4cb0-BBD7-DFA0ABB5ACCA}", "{24ad3ad4-a569-4530-98e1-ab02f9417aa8}" + } - foreach ($category in $namespaces.Keys) { - foreach ($id in $namespaces[$category]) { - $paths = @( - "$basePath\$explorerPath$id", - "$basePath\$wow6432Node$explorerPath$id" - ) + foreach ($category in $namespaces.Keys) { + foreach ($id in $namespaces[$category]) { + $paths = @( + "$basePath\$explorerPath$id", + "$basePath\$wow6432Node$explorerPath$id" + ) - foreach ($path in $paths) { - try { - Remove-Item -Path $path -Recurse -ErrorAction SilentlyContinue - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + foreach ($path in $paths) { + try { + Remove-Item -Path $path -Recurse -ErrorAction SilentlyContinue + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } } } + } + + # homepath additional settings + New-Item -Path $homePath2 -Force *>$null + Set-ItemProperty -Path $homePath2 -Name "(Default)" -Value "CLSID_MSGraphHomeFolder" + Set-ItemProperty -Path $homePath2 -Name "HiddenByDefault" -Value 1 -Type DWord + + # Additional paths + try { + Remove-Item -Path $quickAccessPath -Recurse -ErrorAction SilentlyContinue + Remove-Item -Path $homePath -Recurse -ErrorAction SilentlyContinue + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } + + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - # homepath additional settings - New-Item -Path $homePath2 -Force *>$null - Set-ItemProperty -Path $homePath2 -Name "(Default)" -Value "CLSID_MSGraphHomeFolder" - Set-ItemProperty -Path $homePath2 -Name "HiddenByDefault" -Value 1 -Type DWord + UnpinExplorer + + # Block Microsoft Edge telemetry + Function EdgePrivacySettings { + Write-Host "Adjusting Microsoft Edge privacy settings..." -NoNewline - # Additional paths + $EdgePrivacyCUPath = "HKCU:\Software\Policies\Microsoft\Edge" + $EdgePrivacyAUPath = "HKLM:\SOFTWARE\Policies\Microsoft\Edge" + + $EdgePrivacyKeys = @( + "PaymentMethodQueryEnabled", + "PersonalizationReportingEnabled", + "AddressBarMicrosoftSearchInBingProviderEnabled", + "UserFeedbackAllowed", + "AutofillCreditCardEnabled", + "AutofillAddressEnabled", + "LocalProvidersEnabled", + "SearchSuggestEnabled", + "EdgeShoppingAssistantEnabled", + "WebWidgetAllowed", + "HubsSidebarEnabled" + ) + + $EdgePrivacyKeys | ForEach-Object { + if (-not (Test-Path $EdgePrivacyCUPath)) { + New-Item -Path $EdgePrivacyCUPath -Force *>$null + } try { - Remove-Item -Path $quickAccessPath -Recurse -ErrorAction SilentlyContinue - Remove-Item -Path $homePath -Recurse -ErrorAction SilentlyContinue + Set-ItemProperty -Path $EdgePrivacyCUPath -Name $_ -Value 0 + Set-ItemProperty -Path $EdgePrivacyCUPath -Name "ConfigureDoNotTrack" -Value 1 } catch { Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } - - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } - - UnpinExplorer - - # Block Microsoft Edge telemetry - Function EdgePrivacySettings { - Write-Host "Adjusting Microsoft Edge privacy settings..." -NoNewline - - $EdgePrivacyCUPath = "HKCU:\Software\Policies\Microsoft\Edge" - $EdgePrivacyAUPath = "HKLM:\SOFTWARE\Policies\Microsoft\Edge" - - $EdgePrivacyKeys = @( - "PaymentMethodQueryEnabled", - "PersonalizationReportingEnabled", - "AddressBarMicrosoftSearchInBingProviderEnabled", - "UserFeedbackAllowed", - "AutofillCreditCardEnabled", - "AutofillAddressEnabled", - "LocalProvidersEnabled", - "SearchSuggestEnabled", - "EdgeShoppingAssistantEnabled", - "WebWidgetAllowed", - "HubsSidebarEnabled" - ) - $EdgePrivacyKeys | ForEach-Object { - if (-not (Test-Path $EdgePrivacyCUPath)) { - New-Item -Path $EdgePrivacyCUPath -Force *>$null - } - try { - Set-ItemProperty -Path $EdgePrivacyCUPath -Name $_ -Value 0 - Set-ItemProperty -Path $EdgePrivacyCUPath -Name "ConfigureDoNotTrack" -Value 1 - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + $EdgePrivacyAUKeys = @( + "DoNotTrack", + "QuicAllowed", + "SearchSuggestEnabled", + "AllowSearchAssistant", + "FormFillEnabled", + "PaymentMethodQueryEnabled", + "PersonalizationReportingEnabled", + "AddressBarMicrosoftSearchInBingProviderEnabled", + "UserFeedbackAllowed", + "AutofillCreditCardEnabled", + "AutofillAddressEnabled", + "LocalProvidersEnabled", + "SearchSuggestEnabled", + "EdgeShoppingAssistantEnabled", + "WebWidgetAllowed", + "HubsSidebarEnabled" + ) + + $EdgePrivacyAUKeys | ForEach-Object { + if (-not (Test-Path $EdgePrivacyAUPath)) { + New-Item -Path $EdgePrivacyAUPath -Force *>$null + } + try { + Set-ItemProperty -Path $EdgePrivacyAUPath -Name $_ -Value 0 + Set-ItemProperty -Path $EdgePrivacyAUPath -Name "ConfigureDoNotTrack" -Value 1 + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - $EdgePrivacyAUKeys = @( - "DoNotTrack", - "QuicAllowed", - "SearchSuggestEnabled", - "AllowSearchAssistant", - "FormFillEnabled", - "PaymentMethodQueryEnabled", - "PersonalizationReportingEnabled", - "AddressBarMicrosoftSearchInBingProviderEnabled", - "UserFeedbackAllowed", - "AutofillCreditCardEnabled", - "AutofillAddressEnabled", - "LocalProvidersEnabled", - "SearchSuggestEnabled", - "EdgeShoppingAssistantEnabled", - "WebWidgetAllowed", - "HubsSidebarEnabled" - ) + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - $EdgePrivacyAUKeys | ForEach-Object { - if (-not (Test-Path $EdgePrivacyAUPath)) { - New-Item -Path $EdgePrivacyAUPath -Force *>$null - } - try { - Set-ItemProperty -Path $EdgePrivacyAUPath -Name $_ -Value 0 - Set-ItemProperty -Path $EdgePrivacyAUPath -Name "ConfigureDoNotTrack" -Value 1 - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + EdgePrivacySettings + + Function OfficePrivacySettings { + Write-Host "Adjusting Microsoft Office privacy settings..." -NoNewline + $OfficePrivacyRegistryKeys = @{ + "HKCU:\Software\Microsoft\Office\Common\ClientTelemetry" = @{ + "DisableTelemetry" = 1 + } + "HKCU:\Software\Policies\Microsoft\Office\Common\ClientTelemetry" = @{ + "SendTelemetry" = 3 + } + "HKCU:\Software\Policies\Microsoft\Office\16.0\Common" = @{ + "QMEnable" = 0; + "LinkedIn" = 0 + } + "HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings" = @{ + "InlineTextPrediction" = 0 + } + "HKCU:\Software\Policies\Microsoft\Office\16.0\osm" = @{ + "Enablelogging" = 0; + "EnableUpload" = 0; + "EnableFileObfuscation" = 1 + } + "HKCU:\Software\Policies\Microsoft\Office\16.0\Common\Feedback" = @{ + "SurveyEnabled" = 0; + "Enabled" = 0; + "IncludeEmail" = 0 } - - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } - EdgePrivacySettings - - Function OfficePrivacySettings { - Write-Host "Adjusting Microsoft Office privacy settings..." -NoNewline - $OfficePrivacyRegistryKeys = @{ - "HKCU:\Software\Microsoft\Office\Common\ClientTelemetry" = @{ - "DisableTelemetry" = 1 - } - "HKCU:\Software\Policies\Microsoft\Office\Common\ClientTelemetry" = @{ - "SendTelemetry" = 3 - } - "HKCU:\Software\Policies\Microsoft\Office\16.0\Common" = @{ - "QMEnable" = 0; - "LinkedIn" = 0 - } - "HKCU:\Software\Microsoft\Office\16.0\Common\MailSettings" = @{ - "InlineTextPrediction" = 0 - } - "HKCU:\Software\Policies\Microsoft\Office\16.0\osm" = @{ - "Enablelogging" = 0; - "EnableUpload" = 0; - "EnableFileObfuscation" = 1 - } - "HKCU:\Software\Policies\Microsoft\Office\16.0\Common\Feedback" = @{ - "SurveyEnabled" = 0; - "Enabled" = 0; - "IncludeEmail" = 0 - } + foreach ($key in $OfficePrivacyRegistryKeys.GetEnumerator()) { + $officeregpath = $key.Key + $registryValues = $key.Value + + if (-not (Test-Path $officeregpath)) { + New-Item -Path $officeregpath -Force *>$null } - foreach ($key in $OfficePrivacyRegistryKeys.GetEnumerator()) { - $officeregpath = $key.Key - $registryValues = $key.Value + foreach ($valueName in $registryValues.GetEnumerator()) { + $value = $valueName.Key + $data = $valueName.Value - if (-not (Test-Path $officeregpath)) { - New-Item -Path $officeregpath -Force *>$null + try { + Set-ItemProperty -Path $officeregpath -Name $value -Value $data } - - foreach ($valueName in $registryValues.GetEnumerator()) { - $value = $valueName.Key - $data = $valueName.Value - - try { - Set-ItemProperty -Path $officeregpath -Name $value -Value $data - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } } - - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } - OfficePrivacySettings + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } - Function DisableWindowsSync { - Write-Host "Disabling Windows Sync..." -NoNewline - $WindowsSyncRegistryKeys = @{ - "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync" = @{ - "SyncPolicy" = 5 - } - "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Personalization" = @{ - "Enabled" = 0 - } - "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\BrowserSettings" = @{ - "Enabled" = 0 - } - "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Credentials" = @{ - "Enabled" = 0 - } - "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Language" = @{ - "Enabled" = 0 - } - "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Accessibility" = @{ - "Enabled" = 0 - } - "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Windows" = @{ - "Enabled" = 0 - } + OfficePrivacySettings + + Function DisableWindowsSync { + Write-Host "Disabling Windows Sync..." -NoNewline + $WindowsSyncRegistryKeys = @{ + "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync" = @{ + "SyncPolicy" = 5 + } + "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Personalization" = @{ + "Enabled" = 0 + } + "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\BrowserSettings" = @{ + "Enabled" = 0 } + "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Credentials" = @{ + "Enabled" = 0 + } + "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Language" = @{ + "Enabled" = 0 + } + "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Accessibility" = @{ + "Enabled" = 0 + } + "HKCU:\Software\Microsoft\Windows\CurrentVersion\SettingSync\Groups\Windows" = @{ + "Enabled" = 0 + } + } - foreach ($key in $WindowsSyncRegistryKeys.GetEnumerator()) { - $syncregPath = $key.Key - $registryValues = $key.Value + foreach ($key in $WindowsSyncRegistryKeys.GetEnumerator()) { + $syncregPath = $key.Key + $registryValues = $key.Value - if (-not (Test-Path $syncregPath)) { - New-Item -Path $syncregPath -Force *>$null - } + if (-not (Test-Path $syncregPath)) { + New-Item -Path $syncregPath -Force *>$null + } - foreach ($valueName in $registryValues.GetEnumerator()) { - $value = $valueName.Key - $data = $valueName.Value + foreach ($valueName in $registryValues.GetEnumerator()) { + $value = $valueName.Key + $data = $valueName.Value - try { - Set-ItemProperty -Path $syncregPath -Name $value -Value $data - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + try { + Set-ItemProperty -Path $syncregPath -Name $value -Value $data + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } } - - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } - DisableWindowsSync + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + + DisableWindowsSync - # The function is here because programs add themselves to the right click menu after loading - Function RightClickMenu { - try { - Write-Host "Editing the right click menu..." -NoNewline - # New PS Drives - New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null + # The function is here because programs add themselves to the right click menu after loading + Function RightClickMenu { + try { + Write-Host "Editing the right click menu..." -NoNewline + # New PS Drives + New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null - # Old right click menu - $regPath = "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" - reg.exe add $regPath /f /ve *>$null + # Old right click menu + $regPath = "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" + reg.exe add $regPath /f /ve *>$null - $contextMenuPaths = @( - "HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\SendTo", #remove send to - "HKEY_CLASSES_ROOT\UserLibraryFolder\shellex\ContextMenuHandlers\SendTo", #remove send to - "HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\ModernSharing", #remove share - "HKEY_CLASSES_ROOT\*\shell\pintohomefile", #remove favorites - #remove give access - "HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\Sharing", - "HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers\Sharing", - "HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\Sharing", - "HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers\Sharing", - "HKEY_CLASSES_ROOT\LibraryFolder\background\shellex\ContextMenuHandlers\Sharing", - "HKEY_CLASSES_ROOT\UserLibraryFolder\shellex\ContextMenuHandlers\Sharing", - #remove previous - "HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}", - "HKEY_CLASSES_ROOT\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}", - "HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}", - "HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}", - #remove git - "HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui", - "HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell", - #remove treesize - "HKEY_CLASSES_ROOT\Directory\Background\shell\TreeSize Free", - "HKEY_CLASSES_ROOT\Directory\Background\shell\VSCode" - ) + $contextMenuPaths = @( + "HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\SendTo", #remove send to + "HKEY_CLASSES_ROOT\UserLibraryFolder\shellex\ContextMenuHandlers\SendTo", #remove send to + "HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\ModernSharing", #remove share + "HKEY_CLASSES_ROOT\*\shell\pintohomefile", #remove favorites + #remove give access + "HKEY_CLASSES_ROOT\*\shellex\ContextMenuHandlers\Sharing", + "HKEY_CLASSES_ROOT\Directory\Background\shellex\ContextMenuHandlers\Sharing", + "HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\Sharing", + "HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers\Sharing", + "HKEY_CLASSES_ROOT\LibraryFolder\background\shellex\ContextMenuHandlers\Sharing", + "HKEY_CLASSES_ROOT\UserLibraryFolder\shellex\ContextMenuHandlers\Sharing", + #remove previous + "HKEY_CLASSES_ROOT\AllFilesystemObjects\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}", + "HKEY_CLASSES_ROOT\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}", + "HKEY_CLASSES_ROOT\Directory\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}", + "HKEY_CLASSES_ROOT\Drive\shellex\ContextMenuHandlers\{596AB062-B4D2-4215-9F74-E9109B0A8153}", + #remove git + "HKEY_CLASSES_ROOT\Directory\Background\shell\git_gui", + "HKEY_CLASSES_ROOT\Directory\Background\shell\git_shell", + #remove treesize + "HKEY_CLASSES_ROOT\Directory\Background\shell\TreeSize Free", + "HKEY_CLASSES_ROOT\Directory\Background\shell\VSCode" + ) - foreach ($path in $contextMenuPaths) { - $regPath = $path -replace 'HKCR:\\', 'HKEY_CLASSES_ROOT\' - $cmd = "reg delete `"$regPath`" /f" - Invoke-Expression $cmd *>$null - } + foreach ($path in $contextMenuPaths) { + $regPath = $path -replace 'HKCR:\\', 'HKEY_CLASSES_ROOT\' + $cmd = "reg delete `"$regPath`" /f" + Invoke-Expression $cmd *>$null + } - # New hash menu for right click - $regpath = "HKEY_CLASSES_ROOT\*\shell\hash" - $sha256menu = "HKEY_CLASSES_ROOT\*\shell\hash\shell\02menu" - $md5menu = "HKEY_CLASSES_ROOT\*\shell\hash\shell\03menu" + # New hash menu for right click + $regpath = "HKEY_CLASSES_ROOT\*\shell\hash" + $sha256menu = "HKEY_CLASSES_ROOT\*\shell\hash\shell\02menu" + $md5menu = "HKEY_CLASSES_ROOT\*\shell\hash\shell\03menu" - reg add $regpath /f *>$null - reg add $regpath /v "MUIVerb" /t REG_SZ /d HASH /f *>$null - reg add $regpath /v "SubCommands" /t REG_SZ /d """" /f *>$null - reg add "$regpath\shell" /f *>$null + reg add $regpath /f *>$null + reg add $regpath /v "MUIVerb" /t REG_SZ /d HASH /f *>$null + reg add $regpath /v "SubCommands" /t REG_SZ /d """" /f *>$null + reg add "$regpath\shell" /f *>$null - reg add "$sha256menu" /f *>$null - reg add "$sha256menu\command" /f *>$null - reg add "$sha256menu" /v "MUIVerb" /t REG_SZ /d SHA256 /f *>$null + reg add "$sha256menu" /f *>$null + reg add "$sha256menu\command" /f *>$null + reg add "$sha256menu" /v "MUIVerb" /t REG_SZ /d SHA256 /f *>$null - $tempOut = [System.IO.Path]::GetTempFileName() - $tempErr = [System.IO.Path]::GetTempFileName() - Start-Process cmd.exe -ArgumentList '/c', 'reg add "HKEY_CLASSES_ROOT\*\shell\hash\shell\02menu\command" /ve /d "powershell -noexit get-filehash -literalpath \"%1\" -algorithm SHA256 | format-list" /f' -NoNewWindow -RedirectStandardOutput $tempOut -RedirectStandardError $tempErr - Remove-Item $tempOut -ErrorAction Ignore - Remove-Item $tempErr -ErrorAction Ignore + $tempOut = [System.IO.Path]::GetTempFileName() + $tempErr = [System.IO.Path]::GetTempFileName() + Start-Process cmd.exe -ArgumentList '/c', 'reg add "HKEY_CLASSES_ROOT\*\shell\hash\shell\02menu\command" /ve /d "powershell -noexit get-filehash -literalpath \"%1\" -algorithm SHA256 | format-list" /f' -NoNewWindow -RedirectStandardOutput $tempOut -RedirectStandardError $tempErr + Remove-Item $tempOut -ErrorAction Ignore + Remove-Item $tempErr -ErrorAction Ignore - reg add "$md5menu" /f *>$null - reg add "$md5menu\command" /f *>$null - reg add "$md5menu" /v "MUIVerb" /t REG_SZ /d MD5 /f *>$null + reg add "$md5menu" /f *>$null + reg add "$md5menu\command" /f *>$null + reg add "$md5menu" /v "MUIVerb" /t REG_SZ /d MD5 /f *>$null - $tempOut = [System.IO.Path]::GetTempFileName() - $tempErr = [System.IO.Path]::GetTempFileName() - Start-Process cmd.exe -ArgumentList '/c', 'reg add "HKEY_CLASSES_ROOT\*\shell\hash\shell\03menu\command" /ve /d "powershell -noexit get-filehash -literalpath \"%1\" -algorithm MD5 | format-list" /f' -NoNewWindow -RedirectStandardOutput $tempOut -RedirectStandardError $tempErr - Remove-Item $tempOut -ErrorAction Ignore - Remove-Item $tempErr -ErrorAction Ignore + $tempOut = [System.IO.Path]::GetTempFileName() + $tempErr = [System.IO.Path]::GetTempFileName() + Start-Process cmd.exe -ArgumentList '/c', 'reg add "HKEY_CLASSES_ROOT\*\shell\hash\shell\03menu\command" /ve /d "powershell -noexit get-filehash -literalpath \"%1\" -algorithm MD5 | format-list" /f' -NoNewWindow -RedirectStandardOutput $tempOut -RedirectStandardError $tempErr + Remove-Item $tempOut -ErrorAction Ignore + Remove-Item $tempErr -ErrorAction Ignore - # Add Turn Off Display Menu - $turnOffDisplay = "HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay" - reg add $turnOffDisplay /f *>$null - reg add $turnOffDisplay /v "Icon" /t REG_SZ /d "imageres.dll,-109" /f *>$null - reg add $turnOffDisplay /v "MUIVerb" /t REG_SZ /d "Turn off display" /f *>$null - reg add $turnOffDisplay /v "Position" /t REG_SZ /d "Bottom" /f *>$null - reg add $turnOffDisplay /v "SubCommands" /t REG_SZ /d """" /f *>$null + # Add Turn Off Display Menu + $turnOffDisplay = "HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay" + reg add $turnOffDisplay /f *>$null + reg add $turnOffDisplay /v "Icon" /t REG_SZ /d "imageres.dll,-109" /f *>$null + reg add $turnOffDisplay /v "MUIVerb" /t REG_SZ /d "Turn off display" /f *>$null + reg add $turnOffDisplay /v "Position" /t REG_SZ /d "Bottom" /f *>$null + reg add $turnOffDisplay /v "SubCommands" /t REG_SZ /d """" /f *>$null - reg add "$turnOffDisplay\shell" /f *>$null - $turnOffMenu1 = "$turnOffDisplay\shell\01menu" - reg add $turnOffMenu1 /f *>$null - reg add $turnOffMenu1 /v "Icon" /t REG_SZ /d "powercpl.dll,-513" /f *>$null - reg add $turnOffMenu1 /v "MUIVerb" /t REG_SZ /d "Turn off display" /f *>$null - reg add "$turnOffMenu1\command" /f *>$null - reg add "$turnOffMenu1\command" /ve /d 'cmd /c "powershell.exe -Command \"(Add-Type ''[DllImport(\\\"user32.dll\\\")]public static extern int SendMessage(int hWnd,int hMsg,int wParam,int lParam);'' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)\""' /f *>$null + reg add "$turnOffDisplay\shell" /f *>$null + $turnOffMenu1 = "$turnOffDisplay\shell\01menu" + reg add $turnOffMenu1 /f *>$null + reg add $turnOffMenu1 /v "Icon" /t REG_SZ /d "powercpl.dll,-513" /f *>$null + reg add $turnOffMenu1 /v "MUIVerb" /t REG_SZ /d "Turn off display" /f *>$null + reg add "$turnOffMenu1\command" /f *>$null + reg add "$turnOffMenu1\command" /ve /d 'cmd /c "powershell.exe -Command \"(Add-Type ''[DllImport(\\\"user32.dll\\\")]public static extern int SendMessage(int hWnd,int hMsg,int wParam,int lParam);'' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)\""' /f *>$null - $turnOffMenu2 = "$turnOffDisplay\shell\02menu" - reg add $turnOffMenu2 /f *>$null - reg add $turnOffMenu2 /v "MUIVerb" /t REG_SZ /d "Lock computer and Turn off display" /f *>$null - reg add $turnOffMenu2 /v "CommandFlags" /t REG_DWORD /d 0x20 /f *>$null - reg add $turnOffMenu2 /v "Icon" /t REG_SZ /d "imageres.dll,-59" /f *>$null - reg add "$turnOffMenu2\command" /f *>$null - reg add "$turnOffMenu2\command" /ve /d 'cmd /c "powershell.exe -Command \"(Add-Type ''[DllImport(\\\"user32.dll\\\")]public static extern int SendMessage(int hWnd,int hMsg,int wParam,int lParam);'' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)\" & rundll32.exe user32.dll, LockWorkStation"' /f *>$null - - # Add "Find Empty Folders" - $command = 'powershell.exe -NoExit -Command "Get-ChildItem -Path ''%V'' -Directory -Recurse | Where-Object { $_.GetFileSystemInfos().Count -eq 0 } | ForEach-Object { $_.FullName }"' - - $rightclickregpath = @( - "Registry::HKEY_CLASSES_ROOT\Directory\shell\FindEmptyFolders", - "Registry::HKEY_CLASSES_ROOT\Directory\shell\FindEmptyFolders\command", - "Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\FindEmptyFolders", - "Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\FindEmptyFolders\command", - "Registry::HKEY_CLASSES_ROOT\Drive\shell\FindEmptyFolders", - "Registry::HKEY_CLASSES_ROOT\Drive\shell\FindEmptyFolders\command" - ) + $turnOffMenu2 = "$turnOffDisplay\shell\02menu" + reg add $turnOffMenu2 /f *>$null + reg add $turnOffMenu2 /v "MUIVerb" /t REG_SZ /d "Lock computer and Turn off display" /f *>$null + reg add $turnOffMenu2 /v "CommandFlags" /t REG_DWORD /d 0x20 /f *>$null + reg add $turnOffMenu2 /v "Icon" /t REG_SZ /d "imageres.dll,-59" /f *>$null + reg add "$turnOffMenu2\command" /f *>$null + reg add "$turnOffMenu2\command" /ve /d 'cmd /c "powershell.exe -Command \"(Add-Type ''[DllImport(\\\"user32.dll\\\")]public static extern int SendMessage(int hWnd,int hMsg,int wParam,int lParam);'' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)\" & rundll32.exe user32.dll, LockWorkStation"' /f *>$null + + # Add "Find Empty Folders" + $command = 'powershell.exe -NoExit -Command "Get-ChildItem -Path ''%V'' -Directory -Recurse | Where-Object { $_.GetFileSystemInfos().Count -eq 0 } | ForEach-Object { $_.FullName }"' + + $rightclickregpath = @( + "Registry::HKEY_CLASSES_ROOT\Directory\shell\FindEmptyFolders", + "Registry::HKEY_CLASSES_ROOT\Directory\shell\FindEmptyFolders\command", + "Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\FindEmptyFolders", + "Registry::HKEY_CLASSES_ROOT\Directory\Background\shell\FindEmptyFolders\command", + "Registry::HKEY_CLASSES_ROOT\Drive\shell\FindEmptyFolders", + "Registry::HKEY_CLASSES_ROOT\Drive\shell\FindEmptyFolders\command" + ) - $icon = "imageres.dll,-1025" - $defaultValue = "Find Empty Folders" + $icon = "imageres.dll,-1025" + $defaultValue = "Find Empty Folders" - $rightclickregpath | ForEach-Object { - New-Item -Path $_ -Force | Out-Null - Set-ItemProperty -Path $_ -Name "(Default)" -Value $defaultValue - Set-ItemProperty -Path $_ -Name "Icon" -Value $icon - } + $rightclickregpath | ForEach-Object { + New-Item -Path $_ -Force | Out-Null + Set-ItemProperty -Path $_ -Name "(Default)" -Value $defaultValue + Set-ItemProperty -Path $_ -Name "Icon" -Value $icon + } - # Remove "Edit in Notepad" - Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" ` - -Name "{CA6CC9F1-867A-481E-951E-A28C5E4F01EA}" -Value "Edit in Notepad" - - # Restart Windows Explorer - taskkill /f /im explorer.exe *>$null - Start-Sleep 1 - Start-Process "explorer.exe" -ErrorAction Stop - - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + # Add blocked keys + $blockedkeyPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" + if (-not (Test-Path -Path $blockedkeyPath)) { + New-Item -Path $blockedkeyPath -Force | Out-Null } - - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + else { + ## } + + # Remove "Edit in Notepad" + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{CA6CC9F1-867A-481E-951E-A28C5E4F01EA}" -Value "Edit in Notepad" + + # Remove "Cast to Device" + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Shell Extensions\Blocked" -Name "{7AD84985-87B4-4a16-BE58-8B72A5B390F7}" -Value "Play to Menu" + + # Restart Windows Explorer + taskkill /f /im explorer.exe *>$null + Start-Sleep 1 + Start-Process "explorer.exe" -ErrorAction Stop + + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } - RightClickMenu + RightClickMenu - Function DisableWidgets { - Write-Host "Disabling Windows Widgets..." -NoNewline - try { - Get-AppxPackage -AllUsers -Name *WebExperience* | Remove-AppxPackage -AllUsers *>$null - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - + Function DisableWidgets { + Write-Host "Disabling Windows Widgets..." -NoNewline + try { + Get-AppxPackage -AllUsers -Name *WebExperience* | Remove-AppxPackage -AllUsers *>$null + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + + } - DisableWidgets + DisableWidgets - # Remove Tasks in Task Scheduler - Function RemoveTasks { - $description = @" + # Remove Tasks in Task Scheduler + Function RemoveTasks { + $description = @" +---------------------------------------------+ | If you apply it, | | it turns off windows automatic updates, | | you can only update manually. | +---------------------------------------------+ "@ - Write-Host `n$description -ForegroundColor Yellow + Write-Host `n$description -ForegroundColor Yellow - Write-Host `n"Do you want " -NoNewline - Write-Host "apps and Windows update tasks to be deleted?" -ForegroundColor Yellow -NoNewline - Write-Host "(y/n): " -ForegroundColor Green -NoNewline + Write-Host `n"Do you want " -NoNewline + Write-Host "apps and Windows update tasks to be deleted?" -ForegroundColor Yellow -NoNewline + Write-Host "(y/n): " -ForegroundColor Green -NoNewline - $response = Read-Host - - if ($response -eq 'y' -or $response -eq 'Y') { - Write-Host "Removing Unnecessary Tasks..." -NoNewline - $taskPatterns = @("OneDrive*", "MicrosoftEdge*", "Google*", "Brave*", "Intel*", "klcp*", "MSI*", - "*Adobe*", "CCleaner*", "G2M*", "Opera*", "Overwolf*", "User*", "CreateExplorer*", "{*", "*Samsung*", "*npcap*", - "*Consolidator*", "*Dropbox*", "*Heimdal*", "*klcp*", "*UsbCeip*", "*DmClient*", "*Office Auto*", "*Office Feature*", - "*OfficeTelemetry*", "*GPU*", "Xbl*", "Firefox Back*") - - $windowsUpdateTasks = @( - "\Microsoft\Windows\WindowsUpdate\Scheduled Start", - "\Microsoft\Windows\UpdateOrchestrator\Schedule Scan", - "\Microsoft\Windows\UpdateOrchestrator\Schedule Scan Static Task", - "\Microsoft\Windows\UpdateOrchestrator\Schedule Work", - "\Microsoft\Windows\UpdateOrchestrator\Report policies", - "\Microsoft\Windows\UpdateOrchestrator\UpdateModelTask", - "\Microsoft\Windows\UpdateOrchestrator\USO_UxBroker", - "\Microsoft\Windows\WaaSMedic\PerformRemediation" - ) + $response = Read-Host + + if ($response -eq 'y' -or $response -eq 'Y') { + Write-Host "Removing Unnecessary Tasks..." -NoNewline + $taskPatterns = @("OneDrive*", "MicrosoftEdge*", "Google*", "Brave*", "Intel*", "klcp*", "MSI*", + "*Adobe*", "CCleaner*", "G2M*", "Opera*", "Overwolf*", "User*", "CreateExplorer*", "{*", "*Samsung*", "*npcap*", + "*Consolidator*", "*Dropbox*", "*Heimdal*", "*klcp*", "*UsbCeip*", "*DmClient*", "*Office Auto*", "*Office Feature*", + "*OfficeTelemetry*", "*GPU*", "Xbl*", "Firefox Back*") - $allTasks = Get-ScheduledTask + $windowsUpdateTasks = @( + "\Microsoft\Windows\WindowsUpdate\Scheduled Start", + "\Microsoft\Windows\UpdateOrchestrator\Schedule Scan", + "\Microsoft\Windows\UpdateOrchestrator\Schedule Scan Static Task", + "\Microsoft\Windows\UpdateOrchestrator\Schedule Work", + "\Microsoft\Windows\UpdateOrchestrator\Report policies", + "\Microsoft\Windows\UpdateOrchestrator\UpdateModelTask", + "\Microsoft\Windows\UpdateOrchestrator\USO_UxBroker", + "\Microsoft\Windows\WaaSMedic\PerformRemediation" + ) - foreach ($task in $allTasks) { - $taskName = $task.TaskName - $remove = $false + $allTasks = Get-ScheduledTask - foreach ($pattern in $taskPatterns) { - if ($taskName -like $pattern) { - $remove = $true - break - } - } + foreach ($task in $allTasks) { + $taskName = $task.TaskName + $remove = $false - if ($windowsUpdateTasks -contains $task.TaskPath + $taskName) { + foreach ($pattern in $taskPatterns) { + if ($taskName -like $pattern) { $remove = $true + break } + } + + if ($windowsUpdateTasks -contains $task.TaskPath + $taskName) { + $remove = $true + } - if ($remove) { - try { - Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction Stop - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } + if ($remove) { + try { + Unregister-ScheduledTask -TaskName $taskName -Confirm:$false -ErrorAction Stop + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } } + } - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - elseif ($response -eq 'n' -or $response -eq 'N') { - Write-Host "[Unused tasks will not be deleted.]" -ForegroundColor Red -BackgroundColor Black - } - else { - Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." - RemoveTasks - } } + elseif ($response -eq 'n' -or $response -eq 'N') { + Write-Host "[Unused tasks will not be deleted.]" -ForegroundColor Red -BackgroundColor Black + } + else { + Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." + RemoveTasks + } + } - RemoveTasks + RemoveTasks - # Disable Copilot - Function DisableCopilot { - Write-Host `n"Do you want " -NoNewline - Write-Host "to disable Microsoft Copilot?" -ForegroundColor Yellow -NoNewline - Write-Host "(y/n): " -ForegroundColor Green -NoNewline - $response = Read-Host + # Disable Copilot + Function DisableCopilot { + Write-Host `n"Do you want " -NoNewline + Write-Host "to disable Microsoft Copilot?" -ForegroundColor Yellow -NoNewline + Write-Host "(y/n): " -ForegroundColor Green -NoNewline + $response = Read-Host - if ($response -eq 'y' -or $response -eq 'Y') { - Write-Host "Disabling Microsoft Copilot..." -NoNewline + if ($response -eq 'y' -or $response -eq 'Y') { + Write-Host "Disabling Microsoft Copilot..." -NoNewline - $copilotregPath = "HKCU:\Software\Policies\Microsoft\Windows" - $registryName = "WindowsCopilot" - $registryProperty = "TurnOffWindowsCopilot" - $edgeRegistryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Edge" - $explorerRegistryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" + $copilotregPath = "HKCU:\Software\Policies\Microsoft\Windows" + $registryName = "WindowsCopilot" + $registryProperty = "TurnOffWindowsCopilot" + $edgeRegistryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Edge" + $explorerRegistryPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" - if (-not (Test-Path $copilotregPath)) { - New-Item -Path $copilotregPath -Name $registryName -Force *>$null - } + if (-not (Test-Path $copilotregPath)) { + New-Item -Path $copilotregPath -Name $registryName -Force *>$null + } - New-ItemProperty -Path $copilotregPath\$registryName -Name $registryProperty -Value 1 -PropertyType DWORD -Force *>$null + New-ItemProperty -Path $copilotregPath\$registryName -Name $registryProperty -Value 1 -PropertyType DWORD -Force *>$null - if (-not (Test-Path $edgeRegistryPath)) { - New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\" -Name "Edge" -Force *>$null - } + if (-not (Test-Path $edgeRegistryPath)) { + New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\" -Name "Edge" -Force *>$null + } - New-ItemProperty -Path $edgeRegistryPath -Name "HubsSidebarEnabled" -Value 0 -PropertyType DWORD -Force *>$null + New-ItemProperty -Path $edgeRegistryPath -Name "HubsSidebarEnabled" -Value 0 -PropertyType DWORD -Force *>$null - # Remove Copilot button from File Explorer - Set-ItemProperty -Path $explorerRegistryPath -Name "ShowCopilotButton" -Value 0 -Force *>$null + # Remove Copilot button from File Explorer + Set-ItemProperty -Path $explorerRegistryPath -Name "ShowCopilotButton" -Value 0 -Force *>$null - $lmRegistryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows" - $wowRegistryPath = "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows" + $lmRegistryPath = "HKLM:\SOFTWARE\Policies\Microsoft\Windows" + $wowRegistryPath = "HKLM:\SOFTWARE\WOW6432Node\Policies\Microsoft\Windows" - if (-not (Test-Path $lmRegistryPath\$registryName)) { - New-Item -Path $lmRegistryPath -Name $registryName -Force *>$null - } + if (-not (Test-Path $lmRegistryPath\$registryName)) { + New-Item -Path $lmRegistryPath -Name $registryName -Force *>$null + } - Set-ItemProperty -Path $lmRegistryPath\$registryName -Name $registryProperty -Value 1 -Force *>$null + Set-ItemProperty -Path $lmRegistryPath\$registryName -Name $registryProperty -Value 1 -Force *>$null - if (-not (Test-Path $wowRegistryPath\$registryName)) { - New-Item -Path $wowRegistryPath -Name $registryName -Force *>$null - } + if (-not (Test-Path $wowRegistryPath\$registryName)) { + New-Item -Path $wowRegistryPath -Name $registryName -Force *>$null + } - Set-ItemProperty -Path $wowRegistryPath\$registryName -Name $registryProperty -Value 1 -Force *>$null + Set-ItemProperty -Path $wowRegistryPath\$registryName -Name $registryProperty -Value 1 -Force *>$null - $currentSID = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value - New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS | Out-Null - If (-not (Test-Path "HKU:\$currentSID\Software\Policies\Microsoft\Windows\WindowsCopilot")) { - New-Item -Path "HKU:\$currentSID\Software\Policies\Microsoft\Windows" -Name "WindowsCopilot" -Force *>$null - } - Set-ItemProperty -Path "HKU:\$currentSID\Software\Policies\Microsoft\Windows\WindowsCopilot" -Name "TurnOffWindowsCopilot" -Value 1 - - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - elseif ($response -eq 'n' -or $response -eq 'N') { - Write-Host "[Copilot will not be disabled]" -ForegroundColor Red -BackgroundColor Black - } - else { - Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." - DisableCopilot + $currentSID = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value + New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS | Out-Null + If (-not (Test-Path "HKU:\$currentSID\Software\Policies\Microsoft\Windows\WindowsCopilot")) { + New-Item -Path "HKU:\$currentSID\Software\Policies\Microsoft\Windows" -Name "WindowsCopilot" -Force *>$null } + Set-ItemProperty -Path "HKU:\$currentSID\Software\Policies\Microsoft\Windows\WindowsCopilot" -Name "TurnOffWindowsCopilot" -Value 1 + + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + elseif ($response -eq 'n' -or $response -eq 'N') { + Write-Host "[Copilot will not be disabled]" -ForegroundColor Red -BackgroundColor Black + } + else { + Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." + DisableCopilot } + } - DisableCopilot + DisableCopilot - # Uninstall OneDrive - Function UninstallOneDrive { - Write-Host `n"Do you want " -NoNewline - Write-Host "uninstall Microsoft OneDrive?" -ForegroundColor Yellow -NoNewline - Write-Host "(y/n): " -ForegroundColor Green -NoNewline - $response = Read-Host - if ($response -eq 'y' -or $response -eq 'Y') { - Write-Host "Removing Microsoft OneDrive..." -NoNewline - Silent #silently - try { - # Stop OneDrive and Explorer processes - taskkill /f /im OneDrive.exe *>$null - - # Uninstall OneDrive - $OneDriveSetupPaths = @( - "$env:systemroot\System32\OneDriveSetup.exe", - "$env:systemroot\SysWOW64\OneDriveSetup.exe" - ) - - foreach ($Path in $OneDriveSetupPaths) { - if (Test-Path $Path) { - & $Path /uninstall - } - } + # Uninstall OneDrive + Function UninstallOneDrive { + Write-Host `n"Do you want " -NoNewline + Write-Host "uninstall Microsoft OneDrive?" -ForegroundColor Yellow -NoNewline + Write-Host "(y/n): " -ForegroundColor Green -NoNewline + $response = Read-Host + if ($response -eq 'y' -or $response -eq 'Y') { + Write-Host "Removing Microsoft OneDrive..." -NoNewline + Silent #silently + try { + # Stop OneDrive and Explorer processes + taskkill /f /im OneDrive.exe *>$null - $OneDriveFolders = @( - "$env:localappdata\Microsoft\OneDrive", - "$env:programdata\Microsoft OneDrive", - "$env:systemdrive\OneDriveTemp", - "$env:userprofile\OneDrive" - ) + # Uninstall OneDrive + $OneDriveSetupPaths = @( + "$env:systemroot\System32\OneDriveSetup.exe", + "$env:systemroot\SysWOW64\OneDriveSetup.exe" + ) - $OneDriveFolders | ForEach-Object { - Remove-Item -Path $_ -Recurse -Force -ErrorAction SilentlyContinue + foreach ($Path in $OneDriveSetupPaths) { + if (Test-Path $Path) { + & $Path /uninstall } + } - New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null - $OneDriveClsid = "{018D5C66-4533-4307-9B53-224DE2ED1FE6}" - $ClsidPaths = @( - "HKCR:\CLSID\$OneDriveClsid", - "HKCR:\Wow6432Node\CLSID\$OneDriveClsid" - ) - - foreach ($Path in $ClsidPaths) { - if (-not (Test-Path $Path)) { - New-Item -Path $Path -Force | Out-Null - Set-ItemProperty -Path $Path -Name "System.IsPinnedToNameSpaceTree" -Value 0 - } - } + $OneDriveFolders = @( + "$env:localappdata\Microsoft\OneDrive", + "$env:programdata\Microsoft OneDrive", + "$env:systemdrive\OneDriveTemp", + "$env:userprofile\OneDrive" + ) + + $OneDriveFolders | ForEach-Object { + Remove-Item -Path $_ -Recurse -Force -ErrorAction SilentlyContinue + } - If (Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive") { - New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Recurse -Force -ErrorAction SilentlyContinue + New-PSDrive -Name "HKCR" -PSProvider "Registry" -Root "HKEY_CLASSES_ROOT" | Out-Null + $OneDriveClsid = "{018D5C66-4533-4307-9B53-224DE2ED1FE6}" + $ClsidPaths = @( + "HKCR:\CLSID\$OneDriveClsid", + "HKCR:\Wow6432Node\CLSID\$OneDriveClsid" + ) + + foreach ($Path in $ClsidPaths) { + if (-not (Test-Path $Path)) { + New-Item -Path $Path -Force | Out-Null + Set-ItemProperty -Path $Path -Name "System.IsPinnedToNameSpaceTree" -Value 0 } + } - Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Name "DisableFileSyncNGSC" -Value 1 -Force -ErrorAction SilentlyContinue + If (Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive") { + New-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Recurse -Force -ErrorAction SilentlyContinue + } + + Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\OneDrive" -Name "DisableFileSyncNGSC" -Value 1 -Force -ErrorAction SilentlyContinue - # Remove OneDrive from the registry - reg load "HKU\Default" "C:\Users\Default\NTUSER.DAT" *>$null - reg delete "HKEY_USERS\Default\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "OneDriveSetup" /f *>$null - reg unload "HKU\Default" *>$null + # Remove OneDrive from the registry + reg load "HKU\Default" "C:\Users\Default\NTUSER.DAT" *>$null + reg delete "HKEY_USERS\Default\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "OneDriveSetup" /f *>$null + reg unload "HKU\Default" *>$null - Remove-Item -Path "$env:userprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" -Force -ErrorAction SilentlyContinue + Remove-Item -Path "$env:userprofile\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\OneDrive.lnk" -Force -ErrorAction SilentlyContinue - Start-Sleep 3 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + Start-Sleep 3 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - - } - elseif ($response -eq 'n' -or $response -eq 'N') { - Write-Host "[Windows OneDrive will not be deleted]" -ForegroundColor Red -BackgroundColor Black } - else { - Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." - UninstallOneDrive + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + + } + elseif ($response -eq 'n' -or $response -eq 'N') { + Write-Host "[Windows OneDrive will not be deleted]" -ForegroundColor Red -BackgroundColor Black + } + else { + Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." + UninstallOneDrive } + } - UninstallOneDrive + UninstallOneDrive - # Disable Edge desktop shortcut creation after certain Windows updates are applied - Function UninstallEdge { - Write-Host `n"Do you want " -NoNewline - Write-Host "uninstall Microsoft Edge?" -ForegroundColor Yellow -NoNewline - Write-Host "(y/n): " -ForegroundColor Green -NoNewline - $response = Read-Host - if ($response -eq 'y' -or $response -eq 'Y') { - Write-Host "Removing Microsoft Edge..." -NoNewline + # Disable Edge desktop shortcut creation after certain Windows updates are applied + Function UninstallEdge { + Write-Host `n"Do you want " -NoNewline + Write-Host "uninstall Microsoft Edge?" -ForegroundColor Yellow -NoNewline + Write-Host "(y/n): " -ForegroundColor Green -NoNewline + $response = Read-Host + if ($response -eq 'y' -or $response -eq 'Y') { + Write-Host "Removing Microsoft Edge..." -NoNewline - try { - taskkill /f /im msedge.exe *>$null 2>&1 - taskkill /f /im explorer.exe *>$null 2>&1 + try { + taskkill /f /im msedge.exe *>$null 2>&1 + taskkill /f /im explorer.exe *>$null 2>&1 - # Remove Edge Services - $edgeservices = "edgeupdate", "edgeupdatem" - foreach ($service in $edgeservices) { - Stop-Service -Name $service -Force -ErrorAction SilentlyContinue - Set-Service -Name $service -Status stopped -StartupType disabled -ErrorAction SilentlyContinue - sc.exe delete $service *>$null 2>&1 - } + # Remove Edge Services + $edgeservices = "edgeupdate", "edgeupdatem" + foreach ($service in $edgeservices) { + Stop-Service -Name $service -Force -ErrorAction SilentlyContinue + Set-Service -Name $service -Status stopped -StartupType disabled -ErrorAction SilentlyContinue + sc.exe delete $service *>$null 2>&1 + } - # Uninstall - Edge - $regView = [Microsoft.Win32.RegistryView]::Registry32 - $microsoft = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $regView).OpenSubKey('SOFTWARE\Microsoft', $true) - $edgeClient = $microsoft.OpenSubKey('EdgeUpdate\ClientState\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}', $true) - if ($null -ne $edgeClient.GetValue('experiment_control_labels')) { - $edgeClient.DeleteValue('experiment_control_labels') - } + # Uninstall - Edge + $regView = [Microsoft.Win32.RegistryView]::Registry32 + $microsoft = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $regView).OpenSubKey('SOFTWARE\Microsoft', $true) + $edgeClient = $microsoft.OpenSubKey('EdgeUpdate\ClientState\{56EB18F8-B008-4CBD-B6D2-8C97FE7E9062}', $true) + if ($null -ne $edgeClient.GetValue('experiment_control_labels')) { + $edgeClient.DeleteValue('experiment_control_labels') + } - $microsoft.CreateSubKey('EdgeUpdateDev').SetValue('AllowUninstall', '') + $microsoft.CreateSubKey('EdgeUpdateDev').SetValue('AllowUninstall', '') - $uninstallRegKey = $microsoft.OpenSubKey('Windows\CurrentVersion\Uninstall\Microsoft Edge') - $uninstallString = $uninstallRegKey.GetValue('UninstallString') + ' --force-uninstall' - Silent #silently - Start-Process cmd.exe "/c $uninstallString" -WindowStyle Hidden + $uninstallRegKey = $microsoft.OpenSubKey('Windows\CurrentVersion\Uninstall\Microsoft Edge') + $uninstallString = $uninstallRegKey.GetValue('UninstallString') + ' --force-uninstall' + Silent #silently + Start-Process cmd.exe "/c $uninstallString" -WindowStyle Hidden - $appxStore = '\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore' - $pattern = "HKLM:$appxStore\InboxApplications\Microsoft.MicrosoftEdge_*_neutral__8wekyb3d8bbwe" - $key = (Get-Item -Path $pattern).PSChildName - reg delete "HKLM$appxStore\InboxApplications\$key" /f *>$null + $appxStore = '\SOFTWARE\Microsoft\Windows\CurrentVersion\Appx\AppxAllUserStore' + $pattern = "HKLM:$appxStore\InboxApplications\Microsoft.MicrosoftEdge_*_neutral__8wekyb3d8bbwe" + $key = (Get-Item -Path $pattern).PSChildName + reg delete "HKLM$appxStore\InboxApplications\$key" /f *>$null - #if error use this > $SID = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value - $user = "$env:USERDOMAIN\$env:USERNAME" + #if error use this > $SID = [System.Security.Principal.WindowsIdentity]::GetCurrent().User.Value + $user = "$env:USERDOMAIN\$env:USERNAME" (New-Object System.Security.Principal.NTAccount($user)).Translate([System.Security.Principal.SecurityIdentifier]).Value *>$null - New-Item -Path "HKLM:$appxStore\EndOfLife\$SID\Microsoft.MicrosoftEdge_8wekyb3d8bbwe" -Force *>$null - Get-AppxPackage -Name Microsoft.MicrosoftEdge | Remove-AppxPackage -ErrorAction SilentlyContinue - Remove-Item -Path "HKLM:$appxStore\EndOfLife\$SID\Microsoft.MicrosoftEdge_8wekyb3d8bbwe" -ErrorAction SilentlyContinue + New-Item -Path "HKLM:$appxStore\EndOfLife\$SID\Microsoft.MicrosoftEdge_8wekyb3d8bbwe" -Force *>$null + Get-AppxPackage -Name Microsoft.MicrosoftEdge | Remove-AppxPackage -ErrorAction SilentlyContinue + Remove-Item -Path "HKLM:$appxStore\EndOfLife\$SID\Microsoft.MicrosoftEdge_8wekyb3d8bbwe" -ErrorAction SilentlyContinue - # Delete additional files - $additionalFilesPath = "C:\Windows\System32\MicrosoftEdgeCP.exe" - if (Test-Path -Path $additionalFilesPath) { - $additionalFiles = Get-ChildItem -Path "C:\Windows\System32\MicrosoftEdge*" -File - foreach ($file in $additionalFiles) { - $takeownArgs = "/f $($file.FullName)" - Start-Process -FilePath "takeown.exe" -ArgumentList $takeownArgs -Wait | Out-Null - $icaclsArgs = "`"$($file.FullName)`" /inheritance:e /grant `"$($env:UserName)`":(OI)(CI)F /T /C" - Start-Process -FilePath "icacls.exe" -ArgumentList $icaclsArgs -Wait | Out-Null - Remove-Item -Path $file.FullName -Force -ErrorAction SilentlyContinue - } + # Delete additional files + $additionalFilesPath = "C:\Windows\System32\MicrosoftEdgeCP.exe" + if (Test-Path -Path $additionalFilesPath) { + $additionalFiles = Get-ChildItem -Path "C:\Windows\System32\MicrosoftEdge*" -File + foreach ($file in $additionalFiles) { + $takeownArgs = "/f $($file.FullName)" + Start-Process -FilePath "takeown.exe" -ArgumentList $takeownArgs -Wait | Out-Null + $icaclsArgs = "`"$($file.FullName)`" /inheritance:e /grant `"$($env:UserName)`":(OI)(CI)F /T /C" + Start-Process -FilePath "icacls.exe" -ArgumentList $icaclsArgs -Wait | Out-Null + Remove-Item -Path $file.FullName -Force -ErrorAction SilentlyContinue } + } - $keyPath = "HKLM:\SOFTWARE\Microsoft\EdgeUpdate" - $propertyName = "DoNotUpdateToEdgeWithChromium" - if (-not (Test-Path $keyPath)) { - New-Item -Path $keyPath -Force | Out-Null - } - Set-ItemProperty -Path $keyPath -Name $propertyName -Value 1 -Type DWord -Force -ErrorAction SilentlyContinue + $keyPath = "HKLM:\SOFTWARE\Microsoft\EdgeUpdate" + $propertyName = "DoNotUpdateToEdgeWithChromium" + if (-not (Test-Path $keyPath)) { + New-Item -Path $keyPath -Force | Out-Null + } + Set-ItemProperty -Path $keyPath -Name $propertyName -Value 1 -Type DWord -Force -ErrorAction SilentlyContinue - taskkill /f /im "MicrosoftEdgeUpdate.exe" *>$null + taskkill /f /im "MicrosoftEdgeUpdate.exe" *>$null - $edgeDirectories = Get-ChildItem -Path "C:\Program Files (x86)\Microsoft" -Filter "Edge*" -Directory -ErrorAction SilentlyContinue - if ($edgeDirectories) { - $edgeDirectories | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue - } + $edgeDirectories = Get-ChildItem -Path "C:\Program Files (x86)\Microsoft" -Filter "Edge*" -Directory -ErrorAction SilentlyContinue + if ($edgeDirectories) { + $edgeDirectories | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue + } - $progressPreference = 'SilentlyContinue' - Get-AppxPackage -AllUsers Microsoft.Edge | Remove-AppxPackage -ErrorAction SilentlyContinue | Out-Null + $progressPreference = 'SilentlyContinue' + Get-AppxPackage -AllUsers Microsoft.Edge | Remove-AppxPackage -ErrorAction SilentlyContinue | Out-Null - $paths = @( - "C:\Program Files (x86)\Microsoft\*edge*", - "C:\Program Files (x86)\Microsoft\Edge", - "C:\Program Files (x86)\Microsoft\Temp", - "C:\Program Files (x86)\Microsoft\*" - ) + $paths = @( + "C:\Program Files (x86)\Microsoft\*edge*", + "C:\Program Files (x86)\Microsoft\Edge", + "C:\Program Files (x86)\Microsoft\Temp", + "C:\Program Files (x86)\Microsoft\*" + ) - foreach ($path in $paths) { - $items = Get-ChildItem -Path $path -Recurse -ErrorAction SilentlyContinue - if ($items) { - Remove-Item -Path $path -Force -Recurse -ErrorAction SilentlyContinue *>$null - } + foreach ($path in $paths) { + $items = Get-ChildItem -Path $path -Recurse -ErrorAction SilentlyContinue + if ($items) { + Remove-Item -Path $path -Force -Recurse -ErrorAction SilentlyContinue *>$null } + } - # Final check if Edge is still installed - if (!(Get-Process "msedge" -ErrorAction SilentlyContinue)) { - Start-Process explorer.exe -NoNewWindow - Start-Sleep 4 - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black - } - else { - throw "Microsoft Edge process is still running." - } + # Final check if Edge is still installed + if (!(Get-Process "msedge" -ErrorAction SilentlyContinue)) { + Start-Process explorer.exe -NoNewWindow + Start-Sleep 4 + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + else { + throw "Microsoft Edge process is still running." + } - # Delete the lnk files in the taskbar - $edgedesktop = "$env:USERPROFILE\Desktop\" - $taskBarPath = "$env:USERPROFILE\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar" - $taskBarPath1 = "$env:USERPROFILE\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\" - $taskBarPath2 = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs" - $shortcuts = "Microsoft Edge.lnk", "Microsoft Teams classic.lnk" - - $shortcuts | ForEach-Object { - $fullPath1 = Join-Path $taskBarPath $_ - $fullPath2 = Join-Path $taskBarPath1 $_ - $fullPath3 = Join-Path $taskBarPath2 $_ - $desktoppath = Join-Path $edgedesktop $_ - - if (Test-Path $fullPath1) { - Remove-Item $fullPath1 -ErrorAction Stop - } - - if (Test-Path $fullPath2) { - Remove-Item $fullPath2 -ErrorAction Stop - } - - if (Test-Path $fullPath3) { - Remove-Item $fullPath3 -ErrorAction Stop - } - - if (Test-Path $desktoppath) { - Remove-Item $desktoppath -ErrorAction Stop - } + # Delete the lnk files in the taskbar + $edgedesktop = "$env:USERPROFILE\Desktop\" + $taskBarPath = "$env:USERPROFILE\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar" + $taskBarPath1 = "$env:USERPROFILE\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\" + $taskBarPath2 = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs" + $shortcuts = "Microsoft Edge.lnk", "Microsoft Teams classic.lnk" + + $shortcuts | ForEach-Object { + $fullPath1 = Join-Path $taskBarPath $_ + $fullPath2 = Join-Path $taskBarPath1 $_ + $fullPath3 = Join-Path $taskBarPath2 $_ + $desktoppath = Join-Path $edgedesktop $_ + + if (Test-Path $fullPath1) { + Remove-Item $fullPath1 -ErrorAction Stop } - # Remove Edge tasks - $tasks = Get-ScheduledTask | Where-Object { $_.TaskName -like "*edge*" } + if (Test-Path $fullPath2) { + Remove-Item $fullPath2 -ErrorAction Stop + } - foreach ($task in $tasks) { - Unregister-ScheduledTask -TaskName $task.TaskName -Confirm:$false + if (Test-Path $fullPath3) { + Remove-Item $fullPath3 -ErrorAction Stop } + if (Test-Path $desktoppath) { + Remove-Item $desktoppath -ErrorAction Stop + } } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - - } - elseif ($response -eq 'n' -or $response -eq 'N') { - # Disable Edge Services - $edgeservices = "edgeupdate", "edgeupdatem" - foreach ($service in $edgeservices) { - Stop-Service -Name $service -Force -ErrorAction SilentlyContinue - Set-Service -Name $service -Status stopped -StartupType disabled -ErrorAction SilentlyContinue + # Remove Edge tasks + $tasks = Get-ScheduledTask | Where-Object { $_.TaskName -like "*edge*" } + + foreach ($task in $tasks) { + Unregister-ScheduledTask -TaskName $task.TaskName -Confirm:$false } - Write-Host "[Windows Edge will not be uninstalled]" -ForegroundColor Red -BackgroundColor Black - - } - else { - Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." - UninstallEdge - } - } - - UninstallEdge - Function Removelnks { - Write-Host `n"Removing Desktop shortcuts..." -NoNewline - try { - Get-ChildItem C:\users\Public\Desktop\*.lnk | ForEach-Object { Remove-Item $_ -ErrorAction SilentlyContinue } *>$null - Get-ChildItem $env:USERPROFILE\Desktop\*.lnk | ForEach-Object { Remove-Item $_ -ErrorAction SilentlyContinue } *>$null - Get-ChildItem -Path "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp" -Force | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black } catch { Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black } + } + elseif ($response -eq 'n' -or $response -eq 'N') { - Removelnks - - Function RemoveRecall { - Write-Host `n"Removing Windows 11 Recall..." -NoNewline - try { - Silent - DISM /Online /Disable-Feature /FeatureName:"Recall"​ *>$null - Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + # Disable Edge Services + $edgeservices = "edgeupdate", "edgeupdatem" + foreach ($service in $edgeservices) { + Stop-Service -Name $service -Force -ErrorAction SilentlyContinue + Set-Service -Name $service -Status stopped -StartupType disabled -ErrorAction SilentlyContinue } - catch { - Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black - } - } - - RemoveRecall + Write-Host "[Windows Edge will not be uninstalled]" -ForegroundColor Red -BackgroundColor Black + } + else { + Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." + UninstallEdge + } } - elseif ($response -eq 'n' -or $response -eq 'N') { - Write-Host "[Unnecessary apps will not be uninstalled]" -ForegroundColor Red -BackgroundColor Black + + UninstallEdge + + Function Removelnks { + Write-Host `n"Removing Desktop shortcuts..." -NoNewline + try { + Get-ChildItem C:\users\Public\Desktop\*.lnk | ForEach-Object { Remove-Item $_ -ErrorAction SilentlyContinue } *>$null + Get-ChildItem $env:USERPROFILE\Desktop\*.lnk | ForEach-Object { Remove-Item $_ -ErrorAction SilentlyContinue } *>$null + Get-ChildItem -Path "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp" -Force | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } } - else { - Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." - UnusedApps + + Removelnks + + Function RemoveRecall { + Write-Host `n"Removing Windows 11 Recall..." -NoNewline + try { + Silent + DISM /Online /Disable-Feature /FeatureName:"Recall"​ *>$null + Write-Host "[DONE]" -ForegroundColor Green -BackgroundColor Black + } + catch { + Write-Host "[WARNING] $_" -ForegroundColor Red -BackgroundColor Black + } } + + RemoveRecall + + } + elseif ($response -eq 'n' -or $response -eq 'N') { + Write-Host "[Unnecessary apps will not be uninstalled]" -ForegroundColor Red -BackgroundColor Black } + else { + Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." + UnusedApps + } + } - UnusedApps + UnusedApps - ########## - #endregion Remove Unused Apps/Softwares - ########## + ########## + #endregion Remove Unused Apps/Softwares + ########## - Function Restart { - Write-Host `n"Do you " -NoNewline - Write-Host "want restart?" -NoNewline -ForegroundColor Red -BackgroundColor Black - Write-Host "(y/n): " -NoNewline - $response = Read-Host + Function Restart { + Write-Host `n"Do you " -NoNewline + Write-Host "want restart?" -NoNewline -ForegroundColor Red -BackgroundColor Black + Write-Host "(y/n): " -NoNewline + $response = Read-Host - if ($response -eq 'y' -or $response -eq 'Y') { - cmd.exe /c "shutdown /r /t 0" - } - elseif ($response -eq 'n' -or $response -eq 'N') { - Write-Host("[Restart process cancelled]") -ForegroundColor Red -BackgroundColor Black - } - else { - Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." - } - + if ($response -eq 'y' -or $response -eq 'Y') { + cmd.exe /c "shutdown /r /t 0" } - - Restart - } - else { - Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." - GithubSoftwares + elseif ($response -eq 'n' -or $response -eq 'N') { + Write-Host("[Restart process cancelled]") -ForegroundColor Red -BackgroundColor Black + } + else { + Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." + } + } + + Restart } + else { + Write-Host "Invalid input. Please enter 'y' for yes or 'n' for no." + GithubSoftwares + } +} - GithubSoftwares +GithubSoftwares - ########## - #endregion Install Softwares - ########## +########## +#endregion Install Softwares +##########