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:
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