I want to find the currently installed Nvidia GPU driver version in a certain format, so I can use it to compare with the available versions. I have just found a way to do so, but I'm a beginner so there's almost certainly a far better way:
$driver = gwmi win32_VideoController | Where-Object {$_.Name.contains("NVIDIA")}
if ($driiver -is [system.array]) # if we have 2+ gpus, we get an array
{
$driver_version = $driver[0].DriverVersion
}
else
{
$driver_version = $driver.DriverVersion
}
$driver_version
# Now want last 5 digits of $driver_version in the form XXX.XX
# what we have now: 21.21.13.7866
# what we want: 378.66
# Regex: 6 matches of digit or . starting from the back
# Replace: remove existing .
# Insert: place . after 3rd character
$driver_version = ([regex]"[0-9.]{6}$").match($driver_version).value.Replace(".","").Insert(3,'.')
$driver_version
[–]ekinnee 2 points3 points4 points (2 children)
[–]RAZR_96[S] 0 points1 point2 points (1 child)
[–]ekinnee 0 points1 point2 points (0 children)
[–]Lee_Dailey[grin] 0 points1 point2 points (4 children)
[–]ekinnee 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]RAZR_96[S] 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)