categories/Gpu.ps1
|
# GPU category: vendor detection via Win32_VideoController, then only that vendor's actions. # research.md -> gpu category: deliberately narrow scope for this phase (NVIDIA PowerMizer # only), every action classified Risky - GPU driver registry keys are far less uniformly # documented across vendors/driver versions than the OS-level tweaks in the other categories. function Get-OctaGpuCategory { [CmdletBinding()] param() return [pscustomobject]@{ Id = 'gpu' DisplayName = 'GPU' Description = 'Vendor-specific GPU tweaks (NVIDIA PowerMizer for this phase)' RequiresElevation = $true ContainsIrreversibleActions = $false GetActionsFunction = 'Get-OctaGpuActions' ApplyActionFunction = 'Set-OctaGpuAction' } } function Get-OctaGpuActions { [CmdletBinding()] param() $actions = @() $controllers = @(Get-CimInstance -ClassName Win32_VideoController -ErrorAction SilentlyContinue) $hasNvidia = $controllers | Where-Object { $_.AdapterCompatibility -match 'NVIDIA' -or $_.Name -match 'NVIDIA' } if (-not $hasNvidia) { return $actions } $displayClassKey = 'HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4d36e968-e325-11ce-bfc1-08002be10318}' $subkeys = @(Get-ChildItem -Path $displayClassKey -ErrorAction SilentlyContinue | Where-Object { $_.PSChildName -match '^\d{4}$' }) foreach ($subkey in $subkeys) { $adapterKey = "$displayClassKey\$($subkey.PSChildName)" $providerName = (Get-ItemProperty -Path $adapterKey -Name 'ProviderName' -ErrorAction SilentlyContinue).ProviderName if ($providerName -notmatch 'NVIDIA') { continue } $current = (Get-ItemProperty -Path $adapterKey -Name 'PowerMizerEnable' -ErrorAction SilentlyContinue).PowerMizerEnable if ($null -eq $current -or $current -ne 0) { $displayCurrent = if ($null -eq $current) { '(not set)' } else { $current } $actions += New-OctaAction -TargetType Registry -TargetIdentifier "$adapterKey|PowerMizerEnable" ` -CurrentValue $displayCurrent -PlannedValue 0 -Reversible $true -RiskLevel Risky } } return $actions } function Set-OctaGpuAction { [CmdletBinding()] param([Parameter(Mandatory)]$Action) $keyPath, $valueName = $Action.TargetIdentifier -split '\|', 2 Set-ItemProperty -Path $keyPath -Name $valueName -Value $Action.PlannedValue -Type DWord } |