Help with retreiving hardware information

I

Isaac

Hello,

I'm trying to get this script working. Bascially, it gets a list of
computers from AD, then loops through them to gather hardware informatino
(which it writes to a text file). It runs fine for the first computer, echos
its name then runs the WMI component.

The problem is that after if echos the second computer name it it gets to
line 43 and dies with an error. I'm really new to VB scripting, so I was
hoping someone here could help be figure out what's wrong. Below is the
script in question. Notice that the AD computers are in an OU and not the
default computer container.




-- Begin Paste

'****** This part gets all objetcts at the given AD location (OU, Container,
etc)

Set objDictionary = CreateObject("Scripting.Dictionary")
i = 0

Set objOU = GetObject("LDAP://OU=DOMAINNAMEComputers, DC=DOMAINNAME,
DC=local")
objOU.Filter = Array("Computer")

For Each objComputer in objOU
objDictionary.Add i,objComputer.CN
i = i + 1

Next

For Each objItem in objDictionary
strComputer = objDictionary.Item(objItem)

Wscript.echo strComputer

'***** Open Text File for Output, named %Computername%.tsv in c:\scripts

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("c:\scripts\" & strComputer &
".tsv")

' Enumerates Software
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery _
("SELECT * FROM Win32_Product")
objTextFile.WriteLine "Caption" & vbtab & _
"Description" & vbtab & "Identifying Number" & vbtab & _
"Install Date" & vbtab & "Install Location" & vbtab & _
"Install State" & vbtab & "Name" & vbtab & _
"Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab _
& "Version"
For Each objSoftware in colSoftware
objTextFile.WriteLine objSoftware.Caption & vbtab & _
objSoftware.Description & vbtab & _
objSoftware.IdentifyingNumber & vbtab & _
objSoftware.InstallDate & vbtab & _
objSoftware.InstallLocation & vbtab & _
objSoftware.InstallState & vbtab & _
objSoftware.Name & vbtab & _
objSoftware.PackageCache & vbtab & _
objSoftware.SKUNumber & vbtab & _
objSoftware.Vendor & vbtab & _
objSoftware.Version

Next

Next

objTextFile.Close

------
End Paste



Any help is most appreciated!

Thanks!
 

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

Similar Threads


Top