Skip to content

Check-Gpu

Checks the GPU status

function Bytes2String { param([int64]$Bytes)
	if ($Bytes -lt 1000) { return "$Bytes bytes" }
	$Bytes /= 1000
	if ($Bytes -lt 1000) { return "$($Bytes)KB" }
	$Bytes /= 1000
	if ($Bytes -lt 1000) { return "$($Bytes)MB" }
	$Bytes /= 1000
	if ($Bytes -lt 1000) { return "$($Bytes)GB" }
	$Bytes /= 1000
	return "$($Bytes)TB"
}

try {
	if ($IsLinux) {
		# TODO
	} else {
		$Details = Get-WmiObject Win32_VideoController
		foreach ($GPU in $Details) {
			$Model = $GPU.Caption
			$RAMSize = $GPU.AdapterRAM
			$ResWidth = $GPU.CurrentHorizontalResolution
			$ResHeight = $GPU.CurrentVerticalResolution
			$BitsPerPixel = $GPU.CurrentBitsPerPixel
			$RefreshRate = $GPU.CurrentRefreshRate
			$DriverVersion = $GPU.DriverVersion
			$Status = $GPU.Status
			Write-Host "? $Model GPU ($(Bytes2String $RAMSize) RAM, $($ResWidth)x$($ResHeight) pixels, $($BitsPerPixel)-bit, $($RefreshRate)Hz, driver $DriverVersion) - status $Status"
		}
	}
	exit 0 # success
} catch {
	"?? ERROR: $($Error[0]) (script line $($_.InvocationInfo.ScriptLineNumber))"
	exit 1
}

An interactive directory of PowerShell scripts.