Skip to content

Commit 8ba30c8

Browse files
committed
fix: PS 5.1 compatibility, encoding cleanup, GPU detection, and test fixes
- Fixed PS 7+ conditional assignment syntax across Common.ps1, simplify11.ps1, and UniGetUI.ps1 for PS 5.1 compatibility - Fixed version.json path from root to config/version.json in simplify11.ps1 - Replaced em-dash characters with ASCII hyphens in Common.ps1, Tweaks.Universal.ps1, and ExternalLauncher.ps1 - Fixed trailing whitespace in Organizer.ps1 - Fixed Join-Path calls with 3+ arguments in test files for PS 5.1 two-argument limit - Fixed Invoke-SecureScript test to expect throw on hash mismatch - Added missing Mock Confirm-ExternalTool in Invoke-Tool tests - Fixed Invoke-HybridTweaks to check return values and report when GPUs are not detected - Added NVIDIA GPU detection via display adapter registry scan before applying tweaks - Changed Invoke-NvidiaTweaks and Invoke-AMDTweaks to return boolean success indicators
1 parent cbe12e5 commit 8ba30c8

File tree

12 files changed

+250
-202
lines changed

12 files changed

+250
-202
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ and this project uses [Calendar Versioning](https://calver.org/) (YY.M format).
77

88
## [26.3] - 2026-03-21
99

10+
### March 21 — PowerShell 5.1 compatibility, test fixes, encoding cleanup
11+
12+
- Fixed all PS 7+ `$var = if () {} else {}` assignment syntax across `Common.ps1` (4 instances), `simplify11.ps1`, `UniGetUI.ps1` for PS 5.1 compatibility
13+
- Fixed `simplify11.ps1` version.json path from root to `config/version.json` (was always showing "unknown")
14+
- Fixed em-dash (U+2014) characters in `Common.ps1`, `Tweaks.Universal.ps1`, `ExternalLauncher.ps1` replaced with ASCII hyphen to resolve `PSUseBOMForUnicodeEncodedFile` warnings and PS 5.1 parse failures on files without BOM
15+
- Fixed trailing whitespace in `Organizer.ps1`
16+
- Fixed `Join-Path` calls with 3+ arguments in `Common.Tests.ps1`, `Common.Utilities.Tests.ps1`, `Config.Tests.ps1`, `ExternalLauncher.Tests.ps1` for PS 5.1 (only supports 2-argument `Join-Path`)
17+
- Fixed `Invoke-SecureScript` test to match actual `throw` behavior on hash mismatch
18+
- Fixed `Invoke-Tool` tests with missing `Mock Confirm-ExternalTool` to prevent null reference from unmocked `Read-Host`
19+
- Fixed `Invoke-HybridTweaks` in `Tweaks.GPU.ps1` — no longer reports success when a GPU is not detected; now checks return values from both `Invoke-NvidiaTweaks` and `Invoke-AMDTweaks`
20+
- Added NVIDIA GPU detection to `Invoke-NvidiaTweaks` — scans display adapter registry before applying tweaks, skips with WARNING if not found
21+
- Changed `Invoke-NvidiaTweaks` and `Invoke-AMDTweaks` to return `$true`/`$false` indicating whether tweaks were applied
22+
1023
### March 21 — Power Management split, driver improvements, security hardening, docs overhaul
1124

1225
- Added `Tweaks.Power.ps1` — aggressive power tweaks extracted into separate module with AC power warning

modules/system/Tweaks.GPU.ps1

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,18 @@ function Show-GPUMenu {
1616

1717
function Invoke-HybridTweaks {
1818
Write-Log -Message "Applying tweaks for hybrid GPU configuration (NVIDIA + AMD)..." -Level INFO
19-
Invoke-NvidiaTweaks -NoExit
20-
Invoke-AMDTweaks -NoExit
21-
Write-Log -Message "Successfully applied tweaks for both NVIDIA and AMD GPUs." -Level SUCCESS
19+
$nvidiaOk = Invoke-NvidiaTweaks -NoExit
20+
$amdOk = Invoke-AMDTweaks -NoExit
21+
22+
if ($nvidiaOk -and $amdOk) {
23+
Write-Log -Message "Successfully applied tweaks for both NVIDIA and AMD GPUs." -Level SUCCESS
24+
} elseif ($nvidiaOk) {
25+
Write-Log -Message "Applied NVIDIA tweaks. AMD GPU was not detected." -Level WARNING
26+
} elseif ($amdOk) {
27+
Write-Log -Message "Applied AMD tweaks. NVIDIA GPU was not detected." -Level WARNING
28+
} else {
29+
Write-Log -Message "No supported GPUs detected." -Level ERROR
30+
}
2231
Write-Host ""
2332
Write-Host "$Purple Press any key to return to the GPU menu...$Reset"
2433
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
@@ -30,6 +39,28 @@ function Invoke-NvidiaTweaks {
3039
)
3140

3241
# source - https://github.com/AlchemyTweaks/Verified-Tweaks/blob/main/Nvidia/RmGpsPsEnablePerCpuCoreDpc
42+
# Detect NVIDIA GPU presence
43+
$nvidiaFound = $false
44+
$classPath = "HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}"
45+
foreach ($idx in @("0000", "0001", "0002", "0003")) {
46+
$devPath = "$classPath\$idx"
47+
if (Test-Path $devPath) {
48+
$provider = (Get-ItemProperty -Path $devPath -Name "ProviderName" -ErrorAction SilentlyContinue).ProviderName
49+
if ($provider -match "NVIDIA") {
50+
$nvidiaFound = $true
51+
break
52+
}
53+
}
54+
}
55+
if (-not $nvidiaFound) {
56+
Write-Log -Message "No NVIDIA GPU found in display adapter registry. Skipping NVIDIA tweaks." -Level WARNING
57+
if (-not $NoExit) {
58+
Write-Host "`n$Purple Press any key to return to the GPU menu...$Reset"
59+
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
60+
}
61+
return $false
62+
}
63+
3364
Set-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers" -Name "RmGpsPsEnablePerCpuCoreDpc" -Type "DWord" -Value "1" -Message "Enabled per-CPU core DPC for NVIDIA drivers"
3465
Set-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Control\GraphicsDrivers\Power" -Name "RmGpsPsEnablePerCpuCoreDpc" -Type "DWord" -Value "1" -Message "Enabled power-aware per-CPU core DPC"
3566
Set-RegistryValue -Path "HKLM:\SYSTEM\CurrentControlSet\Services\nvlddmkm" -Name "RmGpsPsEnablePerCpuCoreDpc" -Type "DWord" -Value "1" -Message "Enabled NVIDIA driver per-CPU core DPC"
@@ -41,6 +72,7 @@ function Invoke-NvidiaTweaks {
4172
Write-Host "$Purple Press any key to return to the GPU menu...$Reset"
4273
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
4374
}
75+
return $true
4476
}
4577

4678
function Invoke-AMDTweaks {
@@ -69,7 +101,7 @@ function Invoke-AMDTweaks {
69101
Write-Host "`n$Purple Press any key to return to the GPU menu...$Reset"
70102
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
71103
}
72-
return
104+
return $false
73105
}
74106
Write-Log -Message "Found AMD GPU at $amdPath" -Level INFO
75107
Set-RegistryValue -Path $amdPath -Name "AllowSnapshot" -Type "DWord" -Value "0" -Message "Disabled AMD snapshot feature"
@@ -108,4 +140,5 @@ function Invoke-AMDTweaks {
108140
Write-Host "$Purple Press any key to return to the GPU menu...$Reset"
109141
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
110142
}
143+
return $true
111144
}

modules/system/Tweaks.Universal.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ function Invoke-NetworkTweaks {
193193

194194
# Disable network throttling - especially helpful with gigabit networks
195195
# source - https://youtu.be/EmdosMT5TtA
196-
# 4294967295 = 0xFFFFFFFF (max DWORD) effectively disables network throttling
196+
# 4294967295 = 0xFFFFFFFF (max DWORD) - effectively disables network throttling
197197
Set-RegistryValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile" -Name "NetworkThrottlingIndex" -Type "DWord" -Value "4294967295" -Message "Disabled network throttling for maximum network performance"
198198
Set-RegistryValue -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Multimedia\SystemProfile" -Name "NoLazyMode" -Type "DWord" -Value "1" -Message "Disabled lazy mode for network operations"
199199
}

modules/tools/ExternalLauncher.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Config-driven external tool launcher
2-
# All tool definitions live in config/tools.json no more per-tool wrapper files
2+
# All tool definitions live in config/tools.json - no more per-tool wrapper files
33

44
param(
55
[Parameter(Mandatory = $true)]

modules/unigetui/UniGetUI.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ function Show-AppCategoryMenu {
8080
default { continue }
8181
}
8282

83-
$scriptPath = if ($PSScriptRoot) {
84-
$PSScriptRoot
83+
if ($PSScriptRoot) {
84+
$scriptPath = $PSScriptRoot
8585
} elseif ($MyInvocation.MyCommand.Path) {
86-
Split-Path -Parent $MyInvocation.MyCommand.Path
86+
$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
8787
} else {
88-
$PWD.Path
88+
$scriptPath = $PWD.Path
8989
}
9090

9191
$projectRoot = Split-Path -Parent (Split-Path -Parent $scriptPath)

0 commit comments

Comments
 (0)