Batch – Credant – Create DCID Report

email me

@echo off
cls
color 3a
@title=Query and Log DCID


::Create report name
for /f "tokens=2-4 skip=1 delims=(-./)" %%i in ('echo.^|date') do (
for /f "tokens=1-4 delims=-./ " %%m in ('date /t') do (
(set dow=%%m)&(set %%i=%%n)&(set %%j=%%o)&(set yy=%%p) ) )
For /F "tokens=1,2 delims=:, " %%i in ('TIME /T') Do (Set HHMM=%%i%%j)

@Echo off > g:\DCID\Report_%mm%-%dd%-%yy%_%HHMM%.txt

@Del /q g:\dcid\next.txt

goto MAIN

:STATUS
for /f "tokens=* delims= " %%c in (g:\dcid\mstcomputers.txt) do (
ping %%c -n 1 -w 250 | find "Reply" > nul
if errorlevel 1 (echo %%c OFFLINE & echo %%c>>g:\dcid\next.txt
) else (
ECHO %%c>> g:\dcid\computers.txt
ECHO %%c Online
)
)

:MAIN
for /f "tokens=* delims= " %%a in (g:\dcid\computers.txt) do set PC=%%a& call :LOG
goto END

:LOG
for /f "tokens=2 delims=\" %%e in ('wmic /node:"%PC%" ComputerSystem Get UserName') do set UserName=%%e
set UserName=%UserName: =%
FOR /F "tokens=3* delims=	" %%B IN ('Reg query "\\%PC%\HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\CMGShield" /v DCID') DO SET VAR=%%B
ECHO %PC%,%VAR%,%UserName% >> g:\dcid\Report_%mm%-%dd%-%yy%_%HHMM%.txt
ECHO %PC%,%VAR%,%UserName%
set UserName=
goto END

:END
pause
exit /b 0

Return MAC Addresses from Enterprise Machines

email me

@Echo off
Title Collect MAC Addresses
color 0a
Setlocal EnableDelayedExpansion

:: EXTERNAL VARIABLES
rem Server file(s) path
set Server=C:\Temp\MAC

rem Report name
Set report=Report.txt

rem Enter name of computer text file
Set PCList=computers.txt

:: INTERNAL VARIABLES - do not edit below this line
rem ----------------------------------------------------------------------------
:: CREATES DATE AND TIME TIMESTAMP
for /F "tokens=2-4 delims=/- " %%p in ('date/T') do set mdate=%%r%%p%%q
for /F "tokens=1-2 delims=:- " %%p in ('time/T') do set mtime=%%p%%q

Set ReportN=%mdate%_%mtime%_%report%

cls

:: PROGRAM ROUTINE
:CYCLE
for /f "tokens=* delims= " %%a in (%Server%\%PCList%) do (
echo Loading workstation name...
echo.
ping %%a | find "Reply" > nul
if errorlevel 1 (echo %%a, OFFLINE >> "%ReportN%"
echo %%a not found...
echo %%a>> "offline_machines.txt"
echo.
echo.
%windir%\system32\ping.exe -n 2 127.0.0.1>nul
) else (
echo Scanning %%a for MAC address...
for /f "tokens=1 delims= " %%i in ('getmac /s %%a /U %%a\administrator /P ADD_PASSWORD') do set MAC=%%i

:: NOTE ----------------------------------------------------------------------------------------
:: You could add a different routine here, such as copy a setup file
:: to the computer's UNC, then launch that file using psexec.exe
:: That would allow you to remotely install apps to a list of computers
:: -------------------------------------------------------------------------------------------------

:: Write computer name and mac address to your report
echo %%a, !MAC! >> "%ReportN%"
%windir%\system32\ping.exe -n 2 127.0.0.1>nul
echo.
echo.
)
)
pause
endlocal
exit /b 0