JSI Tip 7689. How do I generate a delineated file containing "DN";"loscr";"profile";"hmdrv";"hmdir"?

Jerold Schulman

January 22, 2004

1 Min Read
ITPro Today logo in a gray background | ITPro Today


Using the Active Directory command-line tools, in a Windows 2000 domain, or Windows Server 2003 domain, I have scripted UserHPL.bat to generate a semi-colon (;) delineated file containing "DN";"loscr";"profile";"hmdrv";"hmdir".

The syntax for using UserHPL.bat is:

UserHPL>FileName

NOTE: The UserHPL.bat script does NOT output accounts that are disabled.

UserHPL.bat contains:

@echo offsetlocalif exist "%TEMP%UserHPL.tm1" del /q "%TEMP%UserHPL.tm1"if exist "%TEMP%UserHPL.tm2" del /q "%TEMP%UserHPL.tm2"set hmdir=set hmdrv=set profile=set loscr=set getit=dsquery user domainroot -name * -limit 0for /f "Tokens=*" %%u in ('%getit%') do set UDN=%%u&call :hplif not exist "%TEMP%UserHPL.tm1" endlocal&goto :EOFsort "%TEMP%UserHPL.tm1" /O "%TEMP%UserHPL.tm2"@echo "DN";"loscr";"profile";"hmdrv";"hmdir"type "%TEMP%UserHPL.tm2"del /q "%TEMP%UserHPL.tm1"del /q "%TEMP%UserHPL.tm2"endlocalgoto :EOF:hplset dis=nofor /f "Tokens=*" %%i in ('dsget user %UDN% -loscr -profile -hmdrv -hmdir -disabled -L') do ( set line=%%i&call :report %%i %%j)goto :EOF:reportif /i "%line:~0,5%" EQU "dsget" goto outif /i "%line:~0,13%" EQU "disabled: yes" set dis=yes&goto :EOFif /i "%line:~0,6%" EQU "hmdir:" if "%line:~7,1%" NEQ "" set hmdir="%line:~7%"&goto :EOF if /i "%line:~0,6%" EQU "hmdrv:" if "%line:~7,1%" NEQ "" set hmdrv="%line:~7%"&goto :EOFif /i "%line:~0,8%" EQU "profile:" if "%line:~9,1%" NEQ "" set profile="%line:~9%"&goto :EOFif /i "%line:~0,6%" EQU "loscr:" if "%line:~7,1%" NEQ "" set loscr="%line:~7%"goto :EOF:outif "%dis%" EQU "yes" goto clear@echo %UDN%;%loscr%;%profile%;%hmdrv%;%hmdir%>>"%TEMP%UserHPL.tm1":clearset dis=noset hmdir=set hmdrv=set profile=set loscr=



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like