Skip to content

Instantly share code, notes, and snippets.

@AlkyoneAoide
Created October 17, 2025 23:48
Show Gist options
  • Save AlkyoneAoide/0565b5e13978f47e42367d37c2cce80a to your computer and use it in GitHub Desktop.
Save AlkyoneAoide/0565b5e13978f47e42367d37c2cce80a to your computer and use it in GitHub Desktop.
Powershell script to rename a CPU and (nvidia) GPU in task manager and related items.
$CPUName = 'Cat Processing Unit'
$GPUName = 'Gaming Pgaming Ugaming'
$NVGPUID = '2206'
# NVGPUID Looks like '2206' for a 3080, '1F36.1050.1028' for a Quadro RTX 3000
###############
function Main {
If ((Test-Administrator) -eq $false) {
$exe = 'powershell.exe'
If (-not ($null -eq (Get-Command 'pwsh.exe' -ErrorAction SilentlyContinue))) {
$exe = 'pwsh.exe'
}
If ($exe -eq 'powershell.exe') {
$currentPolicy = Get-ExecutionPolicy
$acceptablePolicies = @('Bypass', 'RemoteSigned', 'Unrestricted')
If ($currentPolicy -eq 'RemoteSigned') {
Unblock-File -path "$PSCommandPath"
}
If (-not ($currentPolicy -in $acceptablePolicies)) {
Write-Host 'Please allow your system to execute scripts (about_Execution_Policies) or install Powershell 7'
Start-Sleep -Seconds 10
Exit
}
}
Write-Host 'Not running as administrator, prompting for elevation...'
Start-Process -FilePath "$exe" -ArgumentList "-NoProfile -File $PSCommandPath" -Verb RunAs
Exit
}
Set-CPU-Name
$driverTable = Get-GPU-Driver-Table
$INF = Get-NVIDIA-INF $driverTable
Set-NVIDIA-GPU-Name $INF
}
function Test-Administrator {
$user = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
return $user.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
}
function Set-CPU-Name {
$CPURegPath = 'HKLM:\HARDWARE\DESCRIPTION\System\CentralProcessor\0'
$CPURegKey = 'ProcessorNameString'
If (-not (Test-Path $CPURegPath)) {
New-Item -Path $CPURegPath -Force
}
New-ItemProperty -Path $CPURegPath -Name $CPURegKey -Value $CPUName -PropertyType String -Force
Write-Host 'CPU name set'
}
function Get-GPU-Driver-Table {
$drivers = pnputil -enum-drivers -files | Select-String -Pattern '.*Class Name:.*Display' -Context 3, 0
$linePos = 0
$secArr = @()
$driverTable = @{ nDriSec = @() }
ForEach ($line in $($drivers -split '\r?\n|\r')) {
If ($linePos % 4 -eq 2) {
If (-not [string]::IsNullOrEmpty(($line | Select-String -Pattern '.*Provider Name:.*NVIDIA'))) {
$driverTable.numNVDA += 1
$driverTable.nDriSec += [int][Math]::Floor($linePos / 4)
}
}
If ($linePos % 4 -eq 3) {
$secNum = [int][Math]::Floor($linePos / 4)
$driverTable."dri$secNum" = $secArr
$secArr = @()
} Else {
$secArr += $line
}
$linePos++
}
return $driverTable
}
function Get-NVIDIA-INF {
param(
[Parameter(Mandatory, HelpMessage = 'The driver table generated by Get-GPU-Driver-Table.')]
[Hashtable]$driverTable
)
$driverTable.selINF = $driverTable.nDriSec[0]
If ($driverTable.numNVDA -lt 1) {
Write-Host 'You have no NVIDIA driver installed, no NVIDIA GPU name changes were made.'
Exit ### THERE IS AN EXIT HERE
} ElseIf ($driverTable.numNVDA -gt 1) {
$possibleSel = @()
ForEach ($sel in $driverTable.nDriSec) {
$pubName = $driverTable."dri$sel"[0] | Select-String -Pattern '\S*\.inf' | Select-Object -ExpandProperty Matches -First 1
$origName = $driverTable."dri$sel"[1] | Select-String -Pattern '\S*\.inf' | Select-Object -ExpandProperty Matches -First 1
Write-Host "[${sel}]: $pubName ($origName)"
$possibleSel += $sel
}
do {
try {
$default = $driverTable.nDriSec[0]
If (-not ([int]$tmpSel = Read-Host -Prompt 'Please enter the number corresponding to the correct INF file' -ErrorAction SilentlyContinue)) {
$tmpSel = $default
}
$isNum = $true
} catch [System.Management.Automation.PSInvalidOperationException] {
$tmpSel = $default
$isNum = $true
} catch {
$isNum = $false
}
} until ($isNum -and ($tmpSel -in $possibleSel))
$driverTable.selINF = $tmpSel
}
$tableLoc = 'dri' + $driverTable.selINF
$INF = $driverTable."$tableLoc"[0] | Select-String -Pattern '\S*\.inf' | Select-Object -ExpandProperty Matches -First 1
return $INF
}
function Set-NVIDIA-GPU-Name {
param(
[Parameter(Mandatory, HelpMessage = 'The NVIDIA INF file name, in the format "oemXXX.inf" where XXX is a number.')]
[string]$INF
)
$INFPath = "$Env:SystemRoot" + '\INF\' + "$INF"
$INFFileContents = Get-Content -Path $INFPath -Raw
$replaceRegex = '(?<=\r\n|\r|\n)NVIDIA_DEV\.' + "$NVGPUID" + '.*?=.*?".*?"'
$replaceValue = 'NVIDIA_DEV.' + "$NVGPUID" + " = ""$GPUName"""
$newContent = $INFFileContents -replace "$replaceRegex", "$replaceValue"
$newContent | Set-Content -Path $INFPath -NoNewLine
Write-Host 'GPU name set'
}
Main
Write-Host 'Done!'
Start-Sleep -Seconds 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment