Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Polling list of AD computers for pc info

Status
Not open for further replies.

BigC72

MIS
Oct 15, 2004
69
US
I've got a fairly simple script that utilizes a list of pc's exported directly out of AD. The list will contain pc's that are either not turned on or may be gone all together. I've got the script doing what we need IF I provide it with a list of pc's that I know are all "there" and powered on....

My question is how do I taylor the script to identify when a pc in the list is unavailable and move on to the next one in the list without intervention from me?

Here's the code:
Code:
CONST ForAppending = 8
Const GB = 1073741824
Dim logfile


sList = "c:\PCs.txt"    'This file contains all PC names
Set oFSO = CreateObject("Scripting.FileSystemObject")
logfile = "C:\PCinfo_output.txt"
set objLogFile = oFSO.OpenTextFile(logfile, ForAppending, True, True)
aList = Split(oFSO.OpenTextFile(sList).ReadAll, VbCrLf)
For Each sName In aList
GetDetails(sName)
Next

Sub GetDetails(strComputer)

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
For Each objItem in colItems

objLogFile.Write objItem.CSName &","& objItem.SerialNumber &","

Next

Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")

For Each objItem in colItems
memcalc=FormatNumber(objItem.TotalPhysicalMemory/GB,2)

objLogFile.Write objItem.Model &","& objItem.NumberOfProcessors &","& objItem.NumberOfLogicalProcessors &","& memcalc &","

Next

Set objWMIService = GetObject("winmgmts:\\" & strComputer &"\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS")

For Each objItem in colItems

objLogFile.Write objItem.SerialNumber
objLogFile.WriteLine

Next

End Sub
 
Have a look at this FAQ, you should be able to work a ping into your script, and take appropriate action if the machine is not "reachable": faq329-6527
 
Thanks....I'll give that a look and try to incorporate it into what I have.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top