0

Windows 로컬 보안 정책에는 복잡성 요구 사항이 있습니다. 나는배치에서 암호 복잡성을 활성화하는 방법

::this will change the minimum length of the password 
net accounts /minpwlen:8 
::this will change the maximum age of the password 
net accounts /maxpwage:30 
::this will change the minimum age of the password 
net accounts /minpwage:5 
::this will change the number of passwords stored 
net accounts /uniquepw:5 

위는 내가 원하는 대부분입니다하지만 난 수 있도록 방법을 알아낼 수 없습니다, 등 길이, 나이와 같은 다른 암호 물건을 가능하게하는 배치 파일에서 활성화 할 수 있도록하고 싶습니다 배치의 복잡성. 미리 감사드립니다. 또한 다른 아이디어가 있다면 어떻게해야할까요?

답변

0

예전에 비슷한 상황을했고 제가 한 일은이었다

setlocal EnableDelayedExpansion 

SecEdit.exe /export /cfg "%temp%\sec-template.cfg" >nul 2>&1 

set names=MaximumPasswordAge MinimumPasswordLength PasswordComplexity PasswordHistorySize 
set values[MaximumPasswordAge]=90 
set values[MinimumPasswordLength]=6 
set values[PasswordComplexity]=1 
set values[PasswordHistorySize]=10 

for /F "delims== tokens=1,*" %%X in ('type "%temp%\sec-template.cfg"') do (
    call :trim "%%X" 
    set cur_name=!result! 
    for %%I in (%names%) do (
     if "!cur_name!" equ "%%I" (
      set value== !values[%%I]!  
     ) 
    ) 

    if not defined value if "%%Y" neq "" (
     call :trim "%%Y" 
     set value== !result!   
    ) 

    echo !cur_name! !value! >> "%temp%\sec-template2.cfg" 
    set value= 
) 

SecEdit.exe /configure /db secedit.sdb /cfg "%temp%\sec-template2.cfg" >nul 2>&1 

del /q "%temp%\sec-template2*.cfg" >nul 2>&1 

if exist "%~dp0secedit.sdb" del "%~dp0secedit.sdb" >nul 2>&1 

goto :eof 

:trim 
set result=%~1 

set "f=!result:~0,1!" & set "l=!result:~-1!" 

if "!f!" neq " " if "!l!" neq " " goto :eof 
if "!f!" equ " " set result=!result:~1! 
if "!l!" equ " " set result=!result:~0,-1! 

call :trim "!result!" 
goto :eof 

는 도움이되기를 바랍니다.

관련 문제