https://stackoverflow.com/questions/61397665/batch-file-to-get-all-available-graphics-...les-and-output
I previously managed to do this thanks to above link that uses the now depreceated WMIC.
Any ideas on how to do using powershell?
Thanks.
The nearest I could find searching was this ...
But how to put result into a batch file variable ?
https://lindevs.com/methods-to-get-available-gpu-devices-on-windows
C:\> $gpu = (Get-WmiObject Win32_VideoController).Name
C:\> $gpu
Intel(R) UHD Graphics 620
C:\> $gpu -like "Intel"
False
C:\> $gpu -like "*Intel*"
True
C:\> $gpu -like "Intel*"
True
+ Reply to Thread
Results 1 to 12 of 12
-
-
try ..
Code:# Get the video controller information $gpuInfo = Get-WmiObject -Class Win32_VideoController
There is nothing wrong with my environment -
Thanks for trying. When I open a powershell window (as Admin) and enter
$gpu = (Get-WmiObject Win32_VideoController).Name
I just get lots or red error messages? -
I managed to get this to work below, (running from a batch file) sort of. But it incorrectly returned false for all tests.
The weird thing is that when I ran it first (from within a powershell window, not batch file) I got some line, (6 lines) that returned true.
But then further testing returned all false also as in batch file.
I'm testing on a laptop that has a Nvidia GPU.
Powershell $gpu -like 'nvidia'
Powershell $gpu -like 'Nvidia'
echo.
Powershell $gpu -like '*nvidia*'
Powershell $gpu -like '*Nvidia*'
Powershell $gpu -like '*nvenc*'
echo.
Powershell $gpu -like 'nvidia*'
Powershell $gpu -like 'Nvidia*'
echo.
pause
exit -
Try .. in PS
Code:# Get the video controller information $gpuInfo = Get-WmiObject -Class Win32_VideoController # Filter for Nvidia GPUs and display relevant information $NvdaGpus = $gpuInfo | Where-Object { $_.Name -like "*Nvidia*" } if ($NvdaGpus) { foreach ($gpu in $NvdaGpus) { Write-Host "GPU Name : $($gpu.Name)" Write-Host "Driver Version : $($gpu.DriverVersion)" Write-Host "Device ID : $($gpu.DeviceID)" Write-Host "Video Memory: $($gpu.AdapterRAM / 1MB) MB" } }
Code:for /f "tokens=1" %%i in ('cmd /c "wmic path win32_VideoController get name | findstr /I NVIDIA"') do set gpu=%%i echo %gpu%
Last edited by videoAI; 5th Oct 2025 at 22:38.
There is nothing wrong with my environment -
OK. Thanks for all of that. The 2nd. code item I didn't test as (it uses WMIC which is depreceated and now gone AFAIK) the issue is that WMIC is no longer supported by Win 11 AFAIK with the latest 25H2 update.
I already have working version using WMIC which I knew was depreceated but is not much use going forward.
The 1st. item works, tested in a powershell window. Thanks.
FWIW: The code mentioned in this link ( https://lindevs.com/methods-to-get-available-gpu-devices-on-windows ) at page #1. I found also works (Get-WmiObject Win32_VideoController).Name
It's similar to what you suggested in your post #2. except with .name added.
Anyway, happy days, thanks for that. -
I hope this is ok to post as although it's a Powershell query it's not connected to main topic. If not I can create a new topic.
I use this code to do a Powershell division.
REM Getting the FPS value by dividing the before / part by the after / part. An even divide like 25 fps will return 25 only without a trailing period.
SET _DIVIDENT=%_DIVIDENT_INPUT_FPS%
SET _DIVISOR=%_DIVISOR_INPUT_FPS%
for /f "delims=" %%g IN ('powershell -Command [convert]::ToDouble^(\"%_DIVIDENT%\"^)/[convert]::ToDouble^(\"%_DIVISOR%\"^)') DO SET _INPUT_FPS=%%g
Question is: Is it possible to modify the PS query to only return say 3 decimal places?
I can do so using batch by extracting only 3 chars after the period in the resulting batch variable %_INPUT_FPS%, but it would be neater to do it using PS. Thanks.
For a typical 29.970 frame rate the above returns 29.97002997003Last edited by JN-; 6th Oct 2025 at 06:31.
-
try this .. untested
Code:powershell -Command "[math]::Round([convert]::ToDouble(\"%_DIVIDENT%\")/[convert]::ToDouble(\"%_DIVISOR%\"), 3)"
There is nothing wrong with my environment -
Works. Thank you.
I just have to convert to a FOR command now.
Excellent. -
Done.
for /f "delims=" %%g IN ('powershell -Command "[math]::Round^([convert]::ToDouble^(\"!_DIVIDENT!\"^)/[convert]::ToDouble^(\"!_DIVISOR!\"^), !_DEC_PLACES!^)" ') DO SET _FRAME_RATE=%%g
echo Frame rate = [%_FRAME_RATE%] -
I have over 2 dozen small batch utils, already built. Most rely on the ffmpeg utils.
Thanks to other users here I have implemented option to get gpu's available and screen resolution both using WMIC.
Since that's now being removed by MS in latest 25H2 build I needed to replace, modify about 17 of them.
The last item above, Powershell division with decimal places option I wasn't stuck for but a nice to have ability for sure.
Thanks for help with that and Gpu availibility using PS.Last edited by JN-; 6th Oct 2025 at 15:36.
Similar Threads
-
batch to get fpsnum and fpsden value in a variable
By marcorocchini in forum Newbie / General discussionsReplies: 0Last Post: 6th Aug 2022, 12:02 -
How to get media info using powershell?
By iKron in forum Newbie / General discussionsReplies: 1Last Post: 6th May 2022, 08:53 -
how to delete file in powershell only if exist
By marcorocchini in forum Newbie / General discussionsReplies: 3Last Post: 21st Mar 2022, 23:25 -
Batch remux mkv to mp4 with Windows PowerShell
By [ss]vegeta in forum Newbie / General discussionsReplies: 0Last Post: 22nd Dec 2020, 14:48 -
Graphic Cards - Compared and Contrasted
By eager to learn in forum EditingReplies: 1Last Post: 14th Nov 2020, 17:50