====== Gestion des KB sur une machine ====== Ce script permet une gestion succinte des KB sur une machine Windows. @echo off cls TITLE Gestion des KB REM REM Gestion des KB install‚s sur la machine REM REM O.BRizard 2022 REM REM Le script doit etre execut‚ en tant qu'administrateur :_start echo. echo 1 - Rechercher d'un KB install‚. echo 2 - Supprimer un KB install‚. echo 3 - Lister les KB install‚s. echo 4 - Lancer Windows Update. echo 5 - Installer un KB (en test) echo. echo ***** echo q - Quitter echo. :loop set /p choix=Votre choix: if /i "%choix%"=="1" goto :recherche if /i "%choix%"=="2" goto :suppression if /i "%choix%"=="3" goto :liste if /i "%choix%"=="4" goto :update if /i "%choix%"=="5" goto :installKB REM Pour quitter if /i "%choix%"=="" goto :end if /i "%choix%"=="q" goto :end goto :loop :recherche set KBID= :findLoop set /p KBID= Le KB … rechercher, format KBxxxxxxx: if /i "%KBID%"=="" goto findLoop echo. wmic qfe |findstr /r /s /i /m /c:" %KBID% " FOR /F "tokens=* USEBACKQ" %%F IN (`wmic qfe ^|findstr /r /s /i /m /c:" %KBID% "^|find /C " %KBID% "`) DO SET var=%%F if "%var%"=="0" ( echo. && echo *** Le KB %KBID% n'est pas install‚ *** echo. ) goto _start :suppression :suppLoop set KBID= set /p KBID= Le KB … supprimer (sans les letrres KB): if /i "%KBID%"=="" goto suppLoop echo. set /p suppConfirm= Vous ˆtes sure [o/N] ? : if /i "%suppConfirm%"=="o" cls && wusa /uninstall /kb:%KBID% if /i not "%suppConfirm%"=="o" echo Annulation de la suppression. goto _start :liste echo. REM Liste des tous les KB install‚s wmic qfe get Description,HotFixID,InstalledOn goto _start :update echo. REM Lance une mise … jour control update cls goto _start :installKB REM en powershell :installLoop set KBID= set /p KBID= Le KB … installer: if /i "%KBID%"=="" goto installLoop REM On verifie qu'il n'est pas d‚j… install‚ FOR /F "tokens=* USEBACKQ" %%F IN (`wmic qfe ^|findstr /r /s /i /m /c:" %KBID% "^|find /C " %KBID% "`) DO SET var=%%F if "%var%"=="1" ( echo. && echo *** Le KB %KBID% est d‚j… install‚ *** echo. timeout /T 5 goto _start ) REM On install le module powershell pour gerer les updates powershell -Command "& {Install-Module PSWindowsUpdate}" REM On lance l'installation du KB powershell -Command "& {Get-WindowsUpdate -KBArticleID %KBID% -Install}" REM On v‚rifie que le KB est bien install‚ echo. FOR /F "tokens=* USEBACKQ" %%F IN (`wmic qfe ^|findstr /r /s /i /m /c:" %KBID% "^|find /C " %KBID% "`) DO SET var=%%F if "%var%"=="1" echo Le KB %KBID% est bien install‚ if "%var%"=="0" echo Erreur d'installation du KB %KBID% echo. timeout /T 5 goto _start :end echo. echo A bientot... timeout /T 01>nul exit 1