From cbf8d52cf6a45c2ef19c9f55304358a1066377ee Mon Sep 17 00:00:00 2001 From: LeDragoX Date: Fri, 17 May 2024 11:38:24 -0300 Subject: [PATCH 1/5] Removing all the properties changed to **Enable-WindowsSpotlight** - Fix Remove-ItemPropertyVerified --- src/lib/debloat-helper/Remove-ItemPropertyVerified.psm1 | 2 +- src/utils/Individual-Tweaks.psm1 | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/debloat-helper/Remove-ItemPropertyVerified.psm1 b/src/lib/debloat-helper/Remove-ItemPropertyVerified.psm1 index 090f5f7c..98a8000d 100644 --- a/src/lib/debloat-helper/Remove-ItemPropertyVerified.psm1 +++ b/src/lib/debloat-helper/Remove-ItemPropertyVerified.psm1 @@ -20,7 +20,7 @@ function Remove-ItemPropertyVerified() { } Process { - If ((Get-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU\").Property -ccontains $Name) { + If ((Get-Item -Path "$Path").Property -ccontains $Name) { Write-Status -Types "-", $TweakType -Status "Removing: `"$Path>$Name`"" If ($null -ne $Path) { diff --git a/src/utils/Individual-Tweaks.psm1 b/src/utils/Individual-Tweaks.psm1 index 69c775a7..acfba4b9 100644 --- a/src/utils/Individual-Tweaks.psm1 +++ b/src/utils/Individual-Tweaks.psm1 @@ -499,7 +499,12 @@ function Disable-WindowsSpotlight() { function Enable-WindowsSpotlight() { Write-Status -Types "*", "Privacy" -Status "Enabling Windows Spotlight Features..." - Set-ItemPropertyVerified -Path "$PathToCUPoliciesCloudContent" -Name "DisableWindowsSpotlightFeatures" -Type DWord -Value 0 + Remove-ItemPropertyVerified -Path "$PathToCUPoliciesCloudContent" -Name "ConfigureWindowsSpotlight" + Remove-ItemPropertyVerified -Path "$PathToCUPoliciesCloudContent" -Name "IncludeEnterpriseSpotlight" + Remove-ItemPropertyVerified -Path "$PathToCUPoliciesCloudContent" -Name "DisableWindowsSpotlightFeatures" + Remove-ItemPropertyVerified -Path "$PathToCUPoliciesCloudContent" -Name "DisableWindowsSpotlightOnActionCenter" + Remove-ItemPropertyVerified -Path "$PathToCUPoliciesCloudContent" -Name "DisableWindowsSpotlightOnSettings" + Remove-ItemPropertyVerified -Path "$PathToCUPoliciesCloudContent" -Name "DisableWindowsSpotlightWindowsWelcomeExperience" } function Disable-XboxGameBarDVRandMode() { From bb1583339ac3b2d5e3ab882af55d175d0585f164 Mon Sep 17 00:00:00 2001 From: LeDragoX Date: Mon, 20 May 2024 14:09:40 -0300 Subject: [PATCH 2/5] Add warning when path was not found using Remove-ItemPropertyVerified --- .../Remove-ItemPropertyVerified.psm1 | 69 ++++++++++--------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/src/lib/debloat-helper/Remove-ItemPropertyVerified.psm1 b/src/lib/debloat-helper/Remove-ItemPropertyVerified.psm1 index 98a8000d..e3ca4931 100644 --- a/src/lib/debloat-helper/Remove-ItemPropertyVerified.psm1 +++ b/src/lib/debloat-helper/Remove-ItemPropertyVerified.psm1 @@ -20,49 +20,54 @@ function Remove-ItemPropertyVerified() { } Process { - If ((Get-Item -Path "$Path").Property -ccontains $Name) { - Write-Status -Types "-", $TweakType -Status "Removing: `"$Path>$Name`"" + If (Test-Path "$Path") { + If ((Get-Item -Path "$Path").Property -ccontains $Name) { + Write-Status -Types "-", $TweakType -Status "Removing: `"$Path>$Name`"" - If ($null -ne $Path) { - $ScriptBlock += " -Path " - ForEach ($PathParam in $Path) { - $ScriptBlock += "`"$PathParam`", " + If ($null -ne $Path) { + $ScriptBlock += " -Path " + ForEach ($PathParam in $Path) { + $ScriptBlock += "`"$PathParam`", " + } + $ScriptBlock = $ScriptBlock.TrimEnd(", ") } - $ScriptBlock = $ScriptBlock.TrimEnd(", ") - } - If ($null -ne $Name) { - $ScriptBlock += " -Name " - ForEach ($NameParam in $Name) { - $ScriptBlock += "`"$NameParam`", " + If ($null -ne $Name) { + $ScriptBlock += " -Name " + ForEach ($NameParam in $Name) { + $ScriptBlock += "`"$NameParam`", " + } + $ScriptBlock = $ScriptBlock.TrimEnd(", ") } - $ScriptBlock = $ScriptBlock.TrimEnd(", ") - } - If ($null -ne $Include) { - $ScriptBlock += " -Include " - ForEach ($IncludeParam in $Include) { - $ScriptBlock += "`"$IncludeParam`", " + If ($null -ne $Include) { + $ScriptBlock += " -Include " + ForEach ($IncludeParam in $Include) { + $ScriptBlock += "`"$IncludeParam`", " + } + $ScriptBlock = $ScriptBlock.TrimEnd(", ") } - $ScriptBlock = $ScriptBlock.TrimEnd(", ") - } - If ($null -ne $Exclude) { - $ScriptBlock += " -Exclude " - ForEach ($ExcludeParam in $Exclude) { - $ScriptBlock += "`"$ExcludeParam`", " + If ($null -ne $Exclude) { + $ScriptBlock += " -Exclude " + ForEach ($ExcludeParam in $Exclude) { + $ScriptBlock += "`"$ExcludeParam`", " + } + $ScriptBlock = $ScriptBlock.TrimEnd(", ") } - $ScriptBlock = $ScriptBlock.TrimEnd(", ") - } - If ($null -ne $Force) { - $ScriptBlock += " -Force" - } + If ($null -ne $Force) { + $ScriptBlock += " -Force" + } - Write-Verbose "> $ScriptBlock" - Invoke-Expression "$ScriptBlock" + Write-Verbose "> $ScriptBlock" + Invoke-Expression "$ScriptBlock" + } Else { + Write-Status -Types "?", $TweakType -Status "The property `"$Path>$Name`" does not exist." -Warning + + } } Else { - Write-Status -Types "?", $TweakType -Status "The property `"$Path>$Name`" does not exist." -Warning + Write-Status -Types "?", $TweakType -Status "The path(s) `"$Path`" to the property `"$Name`" couldn't be found." -Warning } } } From a54a49bb9e122cb5cf44b08cabcb9664c8254d66 Mon Sep 17 00:00:00 2001 From: LeDragoX Date: Mon, 27 May 2024 14:09:17 -0300 Subject: [PATCH 3/5] Fixed `Remove-ItemPropertyVerified` inaccurately reporting success - The property is now removed correctly, accepting more paths --- .../Remove-ItemPropertyVerified.psm1 | 73 ++++++++++--------- 1 file changed, 37 insertions(+), 36 deletions(-) diff --git a/src/lib/debloat-helper/Remove-ItemPropertyVerified.psm1 b/src/lib/debloat-helper/Remove-ItemPropertyVerified.psm1 index e3ca4931..80e3f545 100644 --- a/src/lib/debloat-helper/Remove-ItemPropertyVerified.psm1 +++ b/src/lib/debloat-helper/Remove-ItemPropertyVerified.psm1 @@ -20,54 +20,55 @@ function Remove-ItemPropertyVerified() { } Process { - If (Test-Path "$Path") { - If ((Get-Item -Path "$Path").Property -ccontains $Name) { - Write-Status -Types "-", $TweakType -Status "Removing: `"$Path>$Name`"" + ForEach ($DirectoryPath in $Path) { + If (Test-Path "$DirectoryPath") { + If ((Get-Item -Path "$DirectoryPath").Property -ccontains $Name) { + Write-Status -Types "-", $TweakType -Status "Removing: `"$DirectoryPath>$Name`"" - If ($null -ne $Path) { - $ScriptBlock += " -Path " - ForEach ($PathParam in $Path) { - $ScriptBlock += "`"$PathParam`", " + If ($null -ne $DirectoryPath) { + $ScriptBlock += " -Path " + $ScriptBlock += "`"$DirectoryPath`", " + $ScriptBlock = $ScriptBlock.TrimEnd(", ") } - $ScriptBlock = $ScriptBlock.TrimEnd(", ") - } - If ($null -ne $Name) { - $ScriptBlock += " -Name " - ForEach ($NameParam in $Name) { - $ScriptBlock += "`"$NameParam`", " + If ($null -ne $Name) { + $ScriptBlock += " -Name " + ForEach ($NameParam in $Name) { + $ScriptBlock += "`"$NameParam`", " + } + $ScriptBlock = $ScriptBlock.TrimEnd(", ") } - $ScriptBlock = $ScriptBlock.TrimEnd(", ") - } - If ($null -ne $Include) { - $ScriptBlock += " -Include " - ForEach ($IncludeParam in $Include) { - $ScriptBlock += "`"$IncludeParam`", " + If ($null -ne $Include) { + $ScriptBlock += " -Include " + ForEach ($IncludeParam in $Include) { + $ScriptBlock += "`"$IncludeParam`", " + } + $ScriptBlock = $ScriptBlock.TrimEnd(", ") } - $ScriptBlock = $ScriptBlock.TrimEnd(", ") - } - If ($null -ne $Exclude) { - $ScriptBlock += " -Exclude " - ForEach ($ExcludeParam in $Exclude) { - $ScriptBlock += "`"$ExcludeParam`", " + If ($null -ne $Exclude) { + $ScriptBlock += " -Exclude " + ForEach ($ExcludeParam in $Exclude) { + $ScriptBlock += "`"$ExcludeParam`", " + } + $ScriptBlock = $ScriptBlock.TrimEnd(", ") } - $ScriptBlock = $ScriptBlock.TrimEnd(", ") - } - If ($null -ne $Force) { - $ScriptBlock += " -Force" - } + If ($null -ne $Force) { + $ScriptBlock += " -Force" + } - Write-Verbose "> $ScriptBlock" - Invoke-Expression "$ScriptBlock" - } Else { - Write-Status -Types "?", $TweakType -Status "The property `"$Path>$Name`" does not exist." -Warning + Write-Verbose "> $ScriptBlock" + Invoke-Expression "$ScriptBlock" + $ScriptBlock = "Remove-ItemProperty" + } Else { + Write-Status -Types "?", $TweakType -Status "The property `"$DirectoryPath>$Name`" does not exist." -Warning + } + } Else { + Write-Status -Types "?", $TweakType -Status "The path(s) `"$DirectoryPath`" to the property `"$Name`" couldn't be found." -Warning } - } Else { - Write-Status -Types "?", $TweakType -Status "The path(s) `"$Path`" to the property `"$Name`" couldn't be found." -Warning } } } From 57c0341452d1669e82d45c676f5bcfb70fa2ce81 Mon Sep 17 00:00:00 2001 From: Haxy Date: Tue, 28 May 2024 13:46:02 +0100 Subject: [PATCH 4/5] Change resolution check to use the primary monitor's working area. (#168) Fixes oversized windows on multiple monitor setups when using dpi scaling. --- src/lib/ui/Get-CurrentResolution.psm1 | 44 +++++---------------------- 1 file changed, 8 insertions(+), 36 deletions(-) diff --git a/src/lib/ui/Get-CurrentResolution.psm1 b/src/lib/ui/Get-CurrentResolution.psm1 index 864d4121..08f7e815 100644 --- a/src/lib/ui/Get-CurrentResolution.psm1 +++ b/src/lib/ui/Get-CurrentResolution.psm1 @@ -5,45 +5,17 @@ function Get-CurrentResolution() { [OutputType([System.Object[]])] param () - # Adapted from: https://www.reddit.com/r/PowerShell/comments/67no9x/comment/dgrry3b/?utm_source=share&utm_medium=web2x&context=3 - $NumberOfScreens = (Get-CimInstance -Namespace root\wmi -ClassName WmiMonitorBasicDisplayParams | Where-Object { $_.Active -like "True" }).Active.Count - $ScreenWidth = $null - $ScreenHeight = $null + Add-Type -AssemblyName System.Windows.Forms - Write-Verbose "Num. of Monitors: $NumberOfScreens" + # Get the primary screen's working area, which takes DPI scaling into account + $primaryScreen = [System.Windows.Forms.Screen]::PrimaryScreen + $bounds = $primaryScreen.Bounds + $workingArea = $primaryScreen.WorkingArea - If ($NumberOfScreens -eq 1) { - # Accepts Scaling/DPI - [System.Windows.Forms.SystemInformation]::VirtualScreen | ForEach-Object { - Write-Verbose "W: $($_.Width) | H: $($_.Height)" + $ScreenWidth = $workingArea.Width + $ScreenHeight = $workingArea.Height - If (!$ScreenWidth -or !$ScreenHeight) { - $ScreenWidth = $_.Width - $ScreenHeight = $_.Height - } + Write-Verbose "Primary Monitor: Width: $ScreenWidth, Height: $ScreenHeight (DPI Scaled)" - If (($_.Width) -and ($_.Width -le $ScreenWidth)) { - $ScreenWidth = $_.Width - $ScreenHeight = $_.Height - } - } - } Else { - # Doesn't accepts Scaling/DPI (rollback method) - Get-CimInstance -Class "Win32_VideoController" | ForEach-Object { - Write-Verbose "W: $($_.CurrentHorizontalResolution) | H: $($_.CurrentVerticalResolution)" - - If (!$ScreenWidth -or !$ScreenHeight) { - $ScreenWidth = $_.CurrentHorizontalResolution - $ScreenHeight = $_.CurrentVerticalResolution - } - - If (($_.CurrentHorizontalResolution) -and ($_.CurrentHorizontalResolution -le $ScreenWidth)) { - $ScreenWidth = $_.CurrentHorizontalResolution - $ScreenHeight = $_.CurrentVerticalResolution - } - } - } - - Write-Verbose "Width: $ScreenWidth, Height: $ScreenHeight" return $ScreenWidth, $ScreenHeight } From c1f2dd5ead181caaa116a5a710c2487dd30b3d6e Mon Sep 17 00:00:00 2001 From: LeDragoX Date: Tue, 28 May 2024 09:49:32 -0300 Subject: [PATCH 5/5] Use Pascal Casing inside Get-CurrentResolution.psm1 - Remove unused variable $bounds --- src/lib/ui/Get-CurrentResolution.psm1 | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/lib/ui/Get-CurrentResolution.psm1 b/src/lib/ui/Get-CurrentResolution.psm1 index 08f7e815..8efad0b2 100644 --- a/src/lib/ui/Get-CurrentResolution.psm1 +++ b/src/lib/ui/Get-CurrentResolution.psm1 @@ -8,12 +8,11 @@ function Get-CurrentResolution() { Add-Type -AssemblyName System.Windows.Forms # Get the primary screen's working area, which takes DPI scaling into account - $primaryScreen = [System.Windows.Forms.Screen]::PrimaryScreen - $bounds = $primaryScreen.Bounds - $workingArea = $primaryScreen.WorkingArea + $PrimaryScreen = [System.Windows.Forms.Screen]::PrimaryScreen + $WorkingArea = $PrimaryScreen.WorkingArea - $ScreenWidth = $workingArea.Width - $ScreenHeight = $workingArea.Height + $ScreenWidth = $WorkingArea.Width + $ScreenHeight = $WorkingArea.Height Write-Verbose "Primary Monitor: Width: $ScreenWidth, Height: $ScreenHeight (DPI Scaled)"