C
Carlos Felipe França da Fonseca
I'm using the following script to get all local user accounts on thousands
of servers:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFileName = objFSO.OpenTextFile("Servers.txt", 1, 0)
Set objOutputFile = objFSO.CreateTextFile("Local Users.txt",True)
Set objNet = CreateObject("WScript.NetWork")
objOutputFile.WriteLine "Verified by:;Date Verified;Server
Name;Name;Comment;Disabled?;Lockout?;Password Changeable?;Password
Expires?;Password Required?"
On Error Resume Next
Do Until objFileName.AtEndOfStream
strServerName = objFileName.ReadLine
Set objWMIService = GetObject("winmgmts:\\" & strServerName &
"\root\cimv2")
If Err.Number > 0 Then
objOutputFile.WriteLine strServerName & ";" & Err.number & " - " &
Err.Description
Err.Clear
Else
Set colItems = objWMIService.ExecQuery ("SELECT * FROM
Win32_UserAccount")
For Each objItem in colItems
objOutputFile.WriteLine objNet.UserName & ";" & Now() & ";" &
strServerName & ";" & objItem.Name & ";" & _
objItem.Description & ";" &
objItem.Disabled & ";" & objItem.Lockout & ";" & _
objItem.PasswordChangeable & ";" &
objItem.PasswordExpires & ";" & _
objItem.PasswordRequired
Next
End If
Loop
WScript.Echo "We're done!!!"
But... the LOOP is not working. The script stucks after all the information
for the first server (in the first line of SERVERS.TXT) is written to the
output file (Local Users.txt).
I'm running the script from a Windows 2000 Advanced Serverand it will get
information of different Windows versions (NT/2000/2003).
When I test the script from my laptop running Windows XP, it works fine.
Even removing "On Error Resume Next", it doesn't return any error. It just
stucks.
Does anybody know why it happens?
Thanks!!!
Carlos Felipe França da Fonseca
of servers:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFileName = objFSO.OpenTextFile("Servers.txt", 1, 0)
Set objOutputFile = objFSO.CreateTextFile("Local Users.txt",True)
Set objNet = CreateObject("WScript.NetWork")
objOutputFile.WriteLine "Verified by:;Date Verified;Server
Name;Name;Comment;Disabled?;Lockout?;Password Changeable?;Password
Expires?;Password Required?"
On Error Resume Next
Do Until objFileName.AtEndOfStream
strServerName = objFileName.ReadLine
Set objWMIService = GetObject("winmgmts:\\" & strServerName &
"\root\cimv2")
If Err.Number > 0 Then
objOutputFile.WriteLine strServerName & ";" & Err.number & " - " &
Err.Description
Err.Clear
Else
Set colItems = objWMIService.ExecQuery ("SELECT * FROM
Win32_UserAccount")
For Each objItem in colItems
objOutputFile.WriteLine objNet.UserName & ";" & Now() & ";" &
strServerName & ";" & objItem.Name & ";" & _
objItem.Description & ";" &
objItem.Disabled & ";" & objItem.Lockout & ";" & _
objItem.PasswordChangeable & ";" &
objItem.PasswordExpires & ";" & _
objItem.PasswordRequired
Next
End If
Loop
WScript.Echo "We're done!!!"
But... the LOOP is not working. The script stucks after all the information
for the first server (in the first line of SERVERS.TXT) is written to the
output file (Local Users.txt).
I'm running the script from a Windows 2000 Advanced Serverand it will get
information of different Windows versions (NT/2000/2003).
When I test the script from my laptop running Windows XP, it works fine.
Even removing "On Error Resume Next", it doesn't return any error. It just
stucks.
Does anybody know why it happens?
Thanks!!!
Carlos Felipe França da Fonseca