Re: Local User Accounts



Hi,

The Win32_UserAccount class is not available on all platforms. See this link
for requirements:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_useraccount.asp

I also found the class is not available on a W2k pro client, although the
link indicates it should be. I would suggest error trapping as follows (in
part):
====================
' On Error Resume Next (commented out)

Do Until objFileName.AtEndOfStream
strFileName = objFilename.ReadLine
On Error Resume Next
Set objWMIService = GetObject("winmgmts:\\" _
& strServerName & "\root\cimv2")
If (Err.Number <> 0) Then
On Error GoTo 0
objOutputFile.WriteLine strServerName & ";" _
& Err.Number & "-" & Err.Description
Else
On Error GoTo 0
Set colItems = ...
...
End If
Loop
==========
Also make sure there are no blank lines in the text file of machine names.

--
Richard
Microsoft MVP Scripting and ADSI
Hilltop Lab - http://www.rlmueller.net

"Carlos Felipe França da Fonseca" <carlos@xxxxxxxxxxxxx> wrote in message
news:uQN5uOT0GHA.5100@xxxxxxxxxxxxxxxxxxxxxxx
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



.



Relevant Pages

  • Enumerate installed software on Windows 2003
    ... Using this scriptomatic script, I am able to list all installed ... our Windows 2003 servers. ... colItems", as colItems is empty. ...
    (microsoft.public.scripting.vbscript)
  • Re: Shutdown Script
    ... requested a shutdown script for all our servers in the datacenter. ... course a simple tool for our Windows Servers was found and utilized, ...
    (comp.unix.questions)
  • Re: Ok to let all ICMP traffic through firewall?
    ... If you want to know, what "Shutdown Windows' servers" does exactly, you ... The program does just the same as Torsten's script in version 2.1, ...
    (comp.security.firewalls)
  • Re: Local User Accounts
    ... of servers: ... I'm running the script from a Windows 2000 Advanced Serverand it will get ... When I test the script from my laptop running Windows XP, ...
    (microsoft.public.windowsxp.wmi)
  • Windows 2003 Removable Storage NTBackup Troubles
    ... We are in the process of upgrading all those servers to Windows 2003, ... With Windows NT and Windows 2000, we used a script to automate the ... problem at this point) the tape device disables itself in the removable ...
    (microsoft.public.windows.server.general)

Loading