Skip navigation

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


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 <Drive:>\folder\PNChg.txt

where <Drive:>\folder\PNChg.txt is the output report file.

JSIPNChg.bat uses only standard commands and contains:

@echo off
if NOT "%1"

"" goto begin :syntax @echo Syntax: JSIPNChg File goto end :begin setlocal set file=%1 if exist %file% del /q %file% for /f "Tokens=*" %%i in ('date /t') do set date=%%i for /f "Tokens=*" %%i in ('time /t') do set time=%%i set 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=%%l set /a year=%yy% if %year% LEQ 80 set /a year=%year% + 2000 if %year% LEQ 99 set /a year=%year% + 1900 set now=%year%%mm%%dd%%tt% for /f "Skip=4 Tokens=*" %%i in ('net users') do call :parse "%%i" endlocal goto end :parse set str=#%1# set str=%str:#"=% set str=%str:"#=% if "%str%"

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

"" goto end set /a cnt=0 for /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 end set /a cnt=0 for /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 end set /a cnt=0 for /f "Tokens=*" %%i in ('net user "%substr%"') do call :parse1 "%%i" goto end :parse1 set /a cnt=%cnt% + 1 set ustr=%1 if %ustr%

"The command completed successfully." goto end set ustr=%ustr:"=% if %cnt% EQU 2 set fullname=%ustr:~29,99% & set actv="Y" if %cnt% EQU 6 goto active if %cnt% EQU 8 goto lastset if %cnt% EQU 10 goto change if %cnt% NEQ 12 goto end set ls="%ustr:~29,3%" if %actv%

"N" goto end if not %ls%

"Yes" goto end if "%change%"

"N" goto end set 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 :active set aa="%ustr:~29,3%" if %aa%

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

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