JSI Tip 1251. Which users can't change their password due to Account Policy Allow Changes in n Days?

Jerold Schulman

April 20, 1999

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


If your Account Policy (User Manager / Policies / Account) is Allow Changes in n Days, you may want a report of user accounts that are temporarily prohibited from changing their password.

On your PDC run:

JSIPNChg folderPNChg.txt

where folderPNChg.txt is the output report file.

JSIPNChg.bat uses only standard commands and contains:

@echo offif NOT "%1"

"" goto begin:syntax@echo Syntax: JSIPNChg File goto end:beginsetlocalset file=%1if exist %file% del /q %file%for /f "Tokens=*" %%i in ('date /t') do set date=%%ifor /f "Tokens=*" %%i in ('time /t') do set time=%%iset now=%date%%time%set now=%now:~4,16%for /f "Tokens=1-4 Delims=/ " %%i in ('@echo %now%') do set mm=%%i&set dd=%%j&set yy=%%k&set tt=%%lset /a year=%yy%if %year% LEQ 80 set /a year=%year% + 2000if %year% LEQ 99 set /a year=%year% + 1900set now=%year%%mm%%dd%%tt%for /f "Skip=4 Tokens=*" %%i in ('net users') do call :parse "%%i"endlocalgoto end:parseset str=#%1#set str=%str:#"=%set str=%str:"#=%if "%str%"

"The command completed successfully." goto endset substr=%str:~0,25%#set substr=%substr:  =%set substr=%substr: #=%set substr=%substr:#=%if "%substr%"

"" goto endset /a cnt=0for /f "Tokens=*" %%i in ('net user "%substr%"') do call :parse1 "%%i"set substr=%str:~25,25%#set substr=%substr: =%set substr=%substr: #=%set substr=%substr:#=%if "%substr%"

"" goto endset /a cnt=0for /f "Tokens=*" %%i in ('net user "%substr%"') do call :parse1 "%%i"set substr=%str:~50,25%#set substr=%substr:  =%set substr=%substr: #=%set substr=%substr:#=%if "%substr%"

"" goto endset /a cnt=0for /f "Tokens=*" %%i in ('net user "%substr%"') do call :parse1 "%%i"goto end:parse1set /a cnt=%cnt% + 1set ustr=%1if %ustr%

"The command completed successfully." goto endset ustr=%ustr:"=%if %cnt% EQU 2 set fullname=%ustr:~29,99% & set actv="Y"if %cnt% EQU 6 goto activeif %cnt% EQU 8 goto lastsetif %cnt% EQU 10 goto changeif %cnt% NEQ 12 goto endset ls="%ustr:~29,3%"if %actv%

"N" goto endif not %ls%

"Yes" goto endif "%change%"

"N" goto endset substr=%substr:"=%set substr=%substr% #set substr=%substr:~0,22%set fullname=%fullname:"=%set fullname=%fullname% #set fullname=%fullname:~0,30%@echo %substr% %change% %fullname% >> %file%goto end:activeset aa="%ustr:~29,3%"if %aa%

"Yes" goto endset actv="N"goto end:lastsetset last="%ustr:~29,16%"goto end:nochgset change=Ngoto end:changeset change=%ustr:~29,16%if "%change%" LEQ %last% goto nochgfor /f "Tokens=1-4 Delims=/ " %%i in ('@echo %change%') do set mm=%%i&set dd=%%j&set yy=%%k&set tt=%%lset /a year=%yy%if %year% LEQ 80 set /a year=%year% + 2000if %year% LEQ 99 set /a year=%year% + 1900set chg=%year%%mm%%dd%%tt%if "%chg%" LEQ "%now%" set change=N:end


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