Skip navigation

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


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 off
setlocal
if 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 0
for /f "Tokens=*" %%u in ('%getit%') do set UDN=%%u&call :hpl
if not exist "%TEMP%\UserHPL.tm1" endlocal&goto :EOF
sort "%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"
endlocal
goto :EOF
:hpl
set dis=no
for /f "Tokens=*" %%i in ('dsget user %UDN% -loscr -profile -hmdrv -hmdir -disabled -L') do (
 set line=%%i&call :report %%i %%j
)
goto :EOF
:report
if /i "%line:~0,5%" EQU "dsget" goto out
if /i "%line:~0,13%" EQU "disabled: yes" set dis=yes&goto :EOF
if /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 :EOF
if /i "%line:~0,8%" EQU "profile:" if "%line:~9,1%" NEQ "" set profile="%line:~9%"&goto :EOF
if /i "%line:~0,6%" EQU "loscr:" if "%line:~7,1%" NEQ "" set loscr="%line:~7%"
goto :EOF
:out
if "%dis%" EQU "yes" goto clear
@echo %UDN%;%loscr%;%profile%;%hmdrv%;%hmdir%>>"%TEMP%\UserHPL.tm1"
:clear
set dis=no
set hmdir=
set hmdrv=
set profile=
set loscr=



Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish