Re: Local User Accounts
- From: "Richard Mueller" <rlmueller-NOSPAM@xxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 5 Sep 2006 21:51:52 -0500
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
.
- References:
- Local User Accounts
- From: Carlos Felipe França da Fonseca
- Local User Accounts
- Prev by Date: Script to Restart PC at 3:00am everyday
- Next by Date: Re: Script to Restart PC at 3:00am everyday
- Previous by thread: Local User Accounts
- Next by thread: Script to Restart PC at 3:00am everyday
- Index(es):
Relevant Pages
|
Loading