Script

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi All,

We need an up to-date list of people in our domain where their accounts are
set to Never on the "Account expires" field.

Please does anyone know of a script that will be able to do this.

Kind Regards.
 
Peter F said:
Hi All,

We need an up to-date list of people in our domain where their accounts are
set to Never on the "Account expires" field.

Please does anyone know of a script that will be able to do this.

Kind Regards.

Try this batch file. It works as long as the user names do not
have embedded spaces.

Line1 @echo off
Line2 net user | more +4 | find /i /v "successfully" >users.1
Line3
Line4 if exist users.2 del users.2
Line5 for /F "tokens=1" %%n in (users.1) do echo %%n>>users.2
Line6 for /F "tokens=2" %%n in (users.1) do echo %%n>>users.2
Line7 for /F "tokens=3" %%n in (users.1) do echo %%n>>users.2
Line8
Line9 type users.2 | sort > users.txt
Line10 del users.1
Line11 del users.2
Line12 echo List of users whose account does not expire. > Expire.txt
Line13 echo Compiled on %date% at %time:~0,5 >> Expire.txt
Line14
Line15 for /F %%a in (users.txt) do net user %%a | find /i "Account expires"
| find /i "never" > nul && echo %%a >> Expire.txt
 
Back
Top