-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpu
50 lines (46 loc) · 1.85 KB
/
gpu
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
cls
$Host.UI.RawUI.WindowTitle = "GPU Friendly Names"
Write-Host "Virtual Display Driver GPU 'Friendly Name' Finder`n"
function Bytes2String {
param([int64]$Bytes)
if ($Bytes -lt 1024) { return "$Bytes bytes" }
$Bytes = [math]::round($Bytes / 1024, 2)
if ($Bytes -lt 1024) { return "$Bytes KB" }
$Bytes = [math]::round($Bytes / 1024, 2)
if ($Bytes -lt 1024) { return "$Bytes MB" }
$Bytes = [math]::round($Bytes / 1024, 2)
if ($Bytes -lt 1024) { return "$Bytes GB" }
$Bytes = [math]::round($Bytes / 1024, 2)
return "$Bytes TB"
}
try {
if ($IsLinux) {
# Linux GPU detection code (to be implemented)
} else {
$Details = Get-WmiObject Win32_VideoController
if ($Details) {
foreach ($GPU in $Details) {
$Model = $GPU.Caption
$RAMSize = $GPU.AdapterRAM
if ($RAMSize -is [array]) {
$RAMSize = $RAMSize[0]
}
# Only display GPUs with RAM size greater than 0
if ($RAMSize -gt 0) {
$ResWidth = $GPU.CurrentHorizontalResolution
$ResHeight = $GPU.CurrentVerticalResolution
$BitsPerPixel = $GPU.CurrentBitsPerPixel
$RefreshRate = $GPU.CurrentRefreshRate
$DriverVersion = $GPU.DriverVersion
$Status = $GPU.Status
Write-Host "Friendly Name: $Model"
Write-Host "($(Bytes2String $RAMSize) RAM, $ResWidth x $ResHeight pixels, $BitsPerPixel-bit, $RefreshRate Hz, driver $DriverVersion) - status $Status`n"
}
}
} else {
Write-Host "No GPU information found."
}
}
} catch {
Write-Host "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($_.Exception.Message)"
}