Thursday, 16 January 2020

cmd - query certain KB on bulk computers

@echo off

set KB=4534273
set LISTFILE=computers.txt


echo --------------------  >> %kb%.txt
echo %date% - %time%  >> %kb%.txt
echo --------------------  >> %kb%.txt

for /f %%a in (%LISTFILE%) do (
    echo.
    echo ---------------------------------------
    echo.
    echo %%a
    ping -n 1 %%a | find "TTL="
    if not errorlevel 1 (
        wmic /Node:%%a qfe list | find "%KB%"

        if not errorlevel 1 (
            echo %%a kb%kb% is installed >> %kb%.txt
        ) else (
            echo %%a kb%kb% is NOT installed >> %kb%.txt
        )
    ) else (
        echo %%a unavailable >> %kb%.txt
    )
)

pause

No comments:

Post a Comment