VideoHelp Forum




+ Reply to Thread
Results 1 to 12 of 12
  1. Member
    Join Date
    Jun 2022
    Location
    Dublin
    Search Comp PM
    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
    Quote Quote  
  2. try ..
    Code:
    # Get the video controller information
    $gpuInfo = Get-WmiObject -Class Win32_VideoController
    There is nothing wrong with my environment
    Quote Quote  
  3. Member
    Join Date
    Jun 2022
    Location
    Dublin
    Search Comp PM
    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?
    Quote Quote  
  4. Member
    Join Date
    Jun 2022
    Location
    Dublin
    Search Comp PM
    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
    Quote Quote  
  5. 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"
        }
    }
    or .. in BAT

    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
    Quote Quote  
  6. Member
    Join Date
    Jun 2022
    Location
    Dublin
    Search Comp PM
    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.
    Quote Quote  
  7. Member
    Join Date
    Jun 2022
    Location
    Dublin
    Search Comp PM
    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.97002997003
    Last edited by JN-; 6th Oct 2025 at 06:31.
    Quote Quote  
  8. try this .. untested
    Code:
    powershell -Command "[math]::Round([convert]::ToDouble(\"%_DIVIDENT%\")/[convert]::ToDouble(\"%_DIVISOR%\"), 3)"
    There is nothing wrong with my environment
    Quote Quote  
  9. Member
    Join Date
    Jun 2022
    Location
    Dublin
    Search Comp PM
    Works. Thank you.

    I just have to convert to a FOR command now.

    Excellent.
    Quote Quote  
  10. Member
    Join Date
    Jun 2022
    Location
    Dublin
    Search Comp PM
    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%]
    Quote Quote  
  11. what are you building exactly?
    There is nothing wrong with my environment
    Quote Quote  
  12. Member
    Join Date
    Jun 2022
    Location
    Dublin
    Search Comp PM
    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.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!