Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Speed Up info_gpu #155

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 32 additions & 6 deletions winfetch.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -702,12 +702,38 @@ function info_cpu {

function info_gpu {
[System.Collections.ArrayList]$lines = @()
#loop through Win32_VideoController
foreach ($gpu in Get-CimInstance -ClassName Win32_VideoController -Property Name -CimSession $cimSession) {
[void]$lines.Add(@{
title = "GPU"
content = $gpu.Name
})
# Get list of GPUs from the Registry
if($LastSeen = (Get-ItemProperty -path HKLM:\SOFTWARE\Microsoft\DirectX\ -ErrorAction SilentlyContinue).LastSeen) {
Get-ChildItem -path HKLM:\SOFTWARE\Microsoft\DirectX\ | Get-ItemProperty | ForEach-Object {
if(($_.Description -ne "Microsoft Basic Render Driver") -and ($_.LastSeen -eq $LastSeen)){
[void]$lines.Add(@{
title = "GPU"
content = $_.Description
})
}
}
}elseif($Devices = Get-ChildItem -path HKLM:\SYSTEM\CurrentControlSet\Enum\PCI\ -Depth 1 -ErrorAction SilentlyContinue) { # Alternative Method 1: Get GPUs from Device Manager's Registry Keys, slightly slower
($Devices | Get-ItemProperty).DeviceDesc | ForEach-Object {
$Device = $_.Substring($_.IndexOf(';') + 1)
if(
$Device -match "NVIDIA GeForce" -or $Device -match "NVIDIA Quadro" -or $Device -match "NVIDIA Tesla" -or $Device -match "NVIDIA GRID" -or`
$Device -match "Radeon" -or`
$Device -match "Intel(R) UHD" -or $Device -match "Intel(R) HD" -or $Device -match "Intel(R) Iris" -or $Device -match "Intel(R) Arc"
){
[void]$lines.Add(@{
title = "GPU"
content = $Device
})
}
}
}else{ # Alternative Method 2: Fallback onto previous implementation
# Loop through Win32_VideoController
foreach ($gpu in Get-CimInstance -ClassName Win32_VideoController -Property Name -CimSession $cimSession) {
[void]$lines.Add(@{
title = "GPU"
content = $gpu.Name
})
}
}
return $lines
}
Expand Down