ikbea said:
Two servers (A & B) are in same domain.
In server A, I want to show all "local" accounts and their status (e.g.
locked, must change password at next logon) of server B, is there any
command, script or utility have this funciton ? Thanks!
Hi
The VBScript below should do this.
Run the script in a command prompt (cmd.exe), like this
cscript.exe "c:\some path\some file.vbs"
If you want to redirect the list to a file:
cscript.exe //Nologo "c:\some path\some file.vbs" >C:\UserInfo.txt
'--------------------8<----------------------
Const ADS_UF_DONT_EXPIRE_PASSWD = &H10000
Set objWshNet = CreateObject("WScript.Network")
' Computer to get the information from
strComputer = "fill in some some name here"
Set objComputer = GetObject("WinNT://" & strComputer & ",computer")
objComputer.Filter = Array("user")
For Each objUser In objComputer
lngFlags = objUser.Get("userFlags")
WScript.Echo "============================================="
WScript.Echo "Name: " & objUser.Name & vbCrLf _
& "FullName: " & objUser.FullName & vbCrLf _
& "Description: " & objUser.Description
If objUser.PasswordExpired = 1 Then
WScript.Echo "User must change password at next logon"
ElseIf (lngFlags And ADS_UF_DONT_EXPIRE_PASSWD) = 0 Then
vExpireDays = DateDiff("d",Now(),CDate(objUser.PasswordExpirationDate))
WScript.Echo "Password Expiration Date: " _
& objUser.PasswordExpirationDate & vbCrLf _
& "Password expires in " & vExpireDays & " days"
Else
WScript.Echo "Password never expires"
End If
If objUser.AccountDisabled = True Then
WScript.Echo "Account is disabled"
Else
WScript.Echo "Account is not disabled"
End If
If objUser.IsAccountLocked = True Then
WScript.Echo "Account is locked"
Else
WScript.Echo "Account is not locked"
End If
Next
'--------------------8<----------------------