🖥️ Batch (CMD)
Export Local User Accounts to CSV (Batch)
Uses wmic to export Local User Accounts (Win32_UserAccount) to a timestamped CSV file.
ExportUserAccountToCsv.bat
@echo off
:: ============================================================
:: ExportUserAccountToCsv.bat
::
:: Exports Local User Accounts (Win32_UserAccount) to a timestamped CSV file next to
:: this script.
:: ============================================================
setlocal EnableDelayedExpansion
for /f "skip=1 tokens=1-2 delims=." %%a in ('wmic os get localdatetime') do if not defined LDT set LDT=%%a
set "OUTFILE=%~dp0useraccount_!LDT:~0,8!-!LDT:~8,6!.csv"
wmic path Win32_UserAccount get Name,FullName,Disabled,Lockout,LocalAccount /format:csv > "%OUTFILE%"
echo Exported to "%OUTFILE%"
endlocal
pause