Show local account of another server

G

Guest

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!
 
T

Torgeir Bakken \(MVP\)

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<----------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top