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! 1 1221
Sorry wrong group.
"Isaac" <pi********@NG.com> wrote in message
news:eH**************@TK2MSFTNGP12.phx.gbl... 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!
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: berthelot samuel |
last post by:
Hi everyone,
I am currently trying to write a report based on a View of SQL Server.
Basically, I have 3 tables : Hardware, SoftwareInstalled and Software
with SoftwareInstalled that keeps track of...
|
by: Morgan Leppink |
last post by:
Hey all -
We are running SQL 2000 with ALL available service packs, etc.
applied. We just built a brand new database server, which has dual
2Ghz XEONs, 2GB memory, and the following disk...
|
by: Ian DeRock |
last post by:
I'm fairly new to XML. As I can see it, XML is a way to organize data
like in a table in a RDB, or the RDB itself. I have used XML in
application data, but did not design the actual XML.
I...
|
by: Scott Dowd |
last post by:
I need explicit example of how to use SetupDi* functions
in both C# .NET and VB .NET to determine device interface
detail for a given device class with interface information
detail. All examples...
|
by: Chua Wen Ching |
last post by:
Hi,
I read from this tutorial at codeproject
Question A:
http://www.codeproject.com/csharp/GsXPathTutorial.asp
regarding xpath.. but i try to apply in my situation, and can't get it...
|
by: wqyuwss |
last post by:
Hi,
We have several core dumps in our product. These core dump can be
reproduced in the same place. That is system function call
std::basic_istream<char,std::char_traits<char>>::getline. The...
|
by: alf |
last post by:
Hi,
is it possible that due to OS crash or mysql itself crash or some e.g.
SCSI failure to lose all the data stored in the table (let's say million
of 1KB rows). In other words what is the worst...
|
by: x01001x |
last post by:
When programming in C (not C++) how does one send information to a
hardware device such as a video card or modem? How is this done in
Linux C programming versus Microsoft C programming?
|
by: Niheel |
last post by:
http://bytes.com/images/howtos/technologies_cut_cost_slow_economy.jpgThere's no escaping the slowing economy. Layoffs are being announced and companies are in cost cutting mode. Whether you are a...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |