Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.
:: =============== :: READ THIS FIRST :: =============== :: * This script require "Computers.txt" file from where it will pick computer names. :: * 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 Computers.txt GOTO ShowErr FOR %%R IN (Computers.txt) DO IF %%~zR EQU 0 GOTO ShowErr IF EXIST CompMgr.ldf DEL /F /Q CompMgr.ldf FOR /F %%c IN ('TYPE Computers.txt') Do ( ECHO Processing: %%c DSQuery Computer -Name %%c |FIND /I "CN=">NUL IF NOT ERRORLEVEL 1 ( FOR /F "delims=*" %%d IN ('DSQuery Computer -Name %%c') DO (( ECHO DN: %%~d ECHO changetype: modify ECHO replace: managedBy ECHO managedBy: %%~d ECHO - ECHO. ECHO DN: %%~d ECHO changetype: modify ECHO delete: managedBy ECHO - ECHO.)>>CompMgr.ldf) ) ELSE (ECHO *** ERROR *** %%c: System NOT Found in AD.) ) ECHO. IF EXIST CompMgr.ldf LDIFDE -I -K -F CompMgr.ldf GOTO EndScript :ShowErr ECHO "Computers.txt" file does not exist or file is empty! :EndScript IF EXIST CompMgr.ldf DEL /F /Q CompMgr.ldf ENDLOCAL :: *** SCRIPT END ***
Join the community of 500,000 technology professionals and ask your questions.