Hello Everyone,

I have a script that is pushed from SMS 2003 on about 800 computers, the script should get a list of everyone who is in the local administrator group and stores it in a txt file. Problem is that Script runs on the first computer gets the information but will not work on the rest, can anyone please help.

thanks

Dim strComputer
Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
'Create a FileSystemObject
Set oFS = CreateObject("Scripting.FileSystemObject")
'Open a text file of computer names
'with one computer name per line
Set objLogFile = oFS.OpenTextFile("\\myserver\App_Installs\Audit\Computers.txt", 8, True, 0)

Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("Group")
For Each objGroup In colGroups
If objGroup.Name = "Administrators" Then
objLogFile.WriteLine "************************************************************"
objLogFile.WriteLine strComputer
objLogFile.WriteLine vTab & objGroup.Name
For Each objUser in objGroup.Members
objLogFile.WriteLine vbTab & vTab & objUser.Name
Next
End If
objLogFile.close
Next
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Answers

0
Dim strComputer
you closed the logfile too soon (ps i never tested this but should work)


Set objNetwork = CreateObject("Wscript.Network")
strComputer = objNetwork.ComputerName
'Create a FileSystemObject
Set oFS = CreateObject("Scripting.FileSystemObject")
'Open a text file of computer names
'with one computer name per line
Set objLogFile = oFS.OpenTextFile("\\myserver\App_Installs\Audit\Computers.txt", 8, True, 0)

Set colGroups = GetObject("WinNT://" & strComputer & "")
colGroups.Filter = Array("Group")
For Each objGroup In colGroups
If objGroup.Name = "Administrators" Then
objLogFile.WriteLine "************************************************************"
objLogFile.WriteLine strComputer
objLogFile.WriteLine vTab & objGroup.Name
For Each objUser in objGroup.Members
objLogFile.WriteLine vbTab & vTab & objUser.Name
Next
End If
Next
objLogFile.close
Answered 05/28/2008 by: jmcfadyen
Fifth Degree Black Belt

Please log in to comment
0
jmcfadyen

Thanks for your reply, I have already tried closing the file at the end but its still not working. What happens is that when SMS runs the script on the first computer then outputs to a log file the log file stays open preventing the script to run on the 2nd computer.

Thanks
Answered 05/29/2008 by: atamo
Senior Yellow Belt

Please log in to comment
0
I'd download ADSI scriptomatic, as AD deals specifically with groups. Regular Scriptomatic WMI might have a collection like that, check it out.

There also used to be an ISAdmin.exe utility. Look through the reskit, there might be something easier to use.
Answered 05/29/2008 by: aogilmor
Ninth Degree Black Belt

Please log in to comment
0
FYI, Admin Script Editor provides a simple wizard for generating ADSI queries in VBScript, PowerShell, KiXtart or AutoIt: http://www.adminscripteditor.com/editor/adsiwizard/
Answered 05/29/2008 by: bkelly
Red Belt

Please log in to comment
0
Folks have tried that before, but the problem exists where you can't keep a .txt file open by multiple computers at once, it gives a sharing violation. If you could somehow stagger each SMS client computer to run the script, it might work. However, SMS can't be managed this way.

Instead, you may want to rename the log file for each client, using the computename variable or something so that you have a bunch of log files instead of one giant one.
Answered 05/29/2008 by: rodtrent
Orange Belt

Please log in to comment
0
Why bother with SMS? Could you not query AD for computers, interrogate them individually then write the log centrally? 800 machines will be a doddle overnight. There are a gazillion scripts around to interrogate AD and grab information. A good place to start is http://www.computerperformance.co.uk/vbscript/index.htm

A script I've used (and heavily adapted for my own purposes) for domain-wide activity is DomainReportManager.VBS, can be obtained here http://www.mousetrax.com/Downloads.html
Answered 05/30/2008 by: VBScab
Red Belt

Please log in to comment
Answer this question or Comment on this question for clarity