Aller au contenu
Yohann LabreuxDécider sous tension

Archives TSSI · Technicien supérieur en support informatique

Batchs divers

Lecteurs réseau, création d’utilisateurs AD en masse, agent FusionInventory, WSUS.

Documents de référence

Connecter un lecteur

net use X: \\nom de l'ordinateur\nom du partage
net use X: \\nom_ordinateur\nom_partage /USER:username password
net use X: /delete

Ajout d'utilisateurs sous l'AD

contenu de "fichier.txt"

Bernard CANEL Compta
Henri LICOMPTE Info
Joséphine MARILLE Market

Voici un batch possible :

@echo off
chcp 1252
for /F "tokens=1,2,3 delims= " %%i in (fichier.txt) do md e:\users\%%i%%j && dsadd user cn="%%i %%j",ou=%%k,ou=company,dc=star,dc=dom -upn %%i@star.dom -samid %%i -fn %%i -ln %%j -display "%%i %%j" -pwd P@s$w0rD -mustchpwd yes -disabled no -hmdrv u: -hmdir \\SRV2K12\users\%%i%%j && icacls e:\users\%%i%%j /grant:r %%i:(OI)(CI)F /Q
PAUSE

Instalation de l'agent fusion de GLPI

premier exemple :

@echo off
set /p srvaddr=Veuillez saisir l'adresse IP du Serveur GLPI/Fusion :
echo.
Echo Veuillez patienter, installation en cours...
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" %temp%\fusionagent-auto\fusion64.exe /acceptlicense /S /add-firewall-exception /server="http://%srvaddr%/glpi/plugins/fusioninventory"
if "%PROCESSOR_ARCHITECTURE%"=="x86" %temp%\fusionagent-auto\fusion32.exe /acceptlicense /S /add-firewall-exception /server="http://%srvaddr%/glpi/plugins/fusioninventory"
cls
echo Installation terminee, inventaire en cours...
call "%programfiles%\FusionInventory-Agent\FusionInventory-Agent.bat"
echo.
Echo Verifier la presence de cet ordinateur dans GLPI, puis appuyer sur une touche pour supprimer l'agent...
pause > NUL
"%programfiles%\FusionInventory-Agent\Uninstall.exe" /S
echo.
Echo Desinstallation terminee, merci d'avoir utilise ce programme.

second exemple :

@echo off
\\srv01\fu\fusioninventory-agent_windows-x64_2.3.11.1.exe /S /acceptlicense /runnow
 /server="http://srv02/glpi/plugins/fusioninventory" /no-ssl-check /installtype=from-scratch
 /installtasks=Inventory /execmode=Service /no-category=Printer /no-start-menu /delaytime=15 /add-firewall-exception

fu est le dossier en partage sur mon serveur contenant l'agent

Troisième exemple (suffisant)

@echo off
\\WINSERV2008\fusioninventory\fusioninventory.exe /S /acceptlicense /add-firewall-exception
/installtype=from-scratch /server="http://winserv2008/glpi/plugins/fusioninventory" /runnow

Batch WSUS

@echo off
Echo Save the batch file "AU_Clean_SID.cmd". This batch file will do the following:
Echo 1.    Stops the wuauserv service
Echo 2.    Deletes the AccountDomainSid registry key (if it exists)
Echo 3.    Deletes the PingID registry key (if it exists)
Echo 4.    Deletes the SusClientId registry key (if it exists)
Echo 5.    Restarts the wuauserv service
Echo 6.    Resets the Authorization Cookie
Echo 7.    More information on http://msmvps.com/Athif
Pause
@echo on
net stop wuauserv
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v AccountDomainSid /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v PingID /f
REG DELETE "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate" /v SusClientId /f
net start wuauserv
wuauclt /resetauthorization /detectnow
Pause
@echo off
Echo This batch file will Force the Update Detection from the AU client:
Echo 1. Stops the Automatic Updates Service (wuauserv)
Echo 2. Deletes the LastWaitTimeout registry key (if it exists)
Echo 3. Deletes the DetectionStartTime registry key (if it exists)
Echo 4. Deletes the NextDetectionTime registry key (if it exists)
Echo 5. Restart the Automatic Updates Service (wuauserv)
Echo 6. Force the detection
Pause
@echo on
net stop wuauserv
REG DELETE "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v LastWaitTimeout /f
REG DELETE "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v DetectionStartTime /f
Reg Delete "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update" /v NextDetectionTime /f
net start wuauserv
wuauclt /detectnow
@echo off
Echo This AU client will now check for the Updates on the Local WSUS Server.
Echo.
Echo This script is provided by http://blogmotion.fr
Pause