:: ===============
:: READ THIS FIRST
:: ===============
:: * This script require "Computers.txt" file on C: drive root from where it will pick computer names.
:: * Successful run will generate "DisableMachineRpt.txt" file on C: drive root.
:: * Copy and paste following script in notepad and save it with any name having .cmd extension.
:: *** SCRIPT START ***
@Echo Off
SETLOCAL EnableDelayedExpansion
IF NOT EXIST C:\Computers.txt Goto ShowErr
FOR %%R IN (Computers.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\DisableMachineRpt.txt DEL /F /Q C:\DisableMachineRpt.txt
FOR /F %%c IN ('Type C:\Computers.txt') Do (
Echo Processing: %%c
DSQuery Computer -Name %%c | Find /I "CN=" >NUL
IF NOT ErrorLevel 1 (
DSQuery Computer -Name %%c |DSMod Computer -disabled yes >>C:\DisableMachineRpt.txt
) ELSE (Echo %%c: ERROR - System NOT Found in AD. >>C:\DisableMachineRpt.txt
)
Goto EndScript
:ShowErr
Echo "C:\Computers.txt" file does not exist or file is empty!
:EndScript
ENDLOCAL
:: *** SCRIPT END ***
Main Topics
Browse All Topics





by: OmegaJuniorPosted on 2007-09-15 at 07:25:38ID: 19897594
I'd look into WMI or PowerShell... but I have no experience in either, sorry.