I'm writing a script to query for the Serial number of machines on our network. I keep getting an error and have narrowed it down to line 16 where I'm calling an array element. I've tried single quotes, double quotes, and no quotes and can't get it to work but the script runs without error when the array element is removed. Can anyone explain that to me? Thank you in advance..
Code:
Break ON
$ = SetOption("WrapAtEOL","ON")
$LogFile = "C:\computer_list.txt"
$OutputFile = "C:\output_file.txt"
$OpenListFile = OPEN(4,$LogFile,2)
$OpenLogFile = OPEN(5,$OutputFile,5)
If $OpenListFile = 0
$CurrentPC = ReadLine(4)
If $OpenLogFile = 0
DO
? $CurrentPC
$ = WRITELINE(5,"$CurrentPC, ")
$MyBIOSInfo = GetBIOSInfo("$CurrentPC")
$ = WRITELINE(5, "$BIOSArray[3]" + @CRLF)
$CurrentPC = ReadLine(4)
UNTIL @ERROR = -1
ENDIF
ENDIF
CLOSE(4)
CLOSE(5)
Sleep 5
Function GetBIOSInfo($Computer)
Dim $Computer, $WMIService, $BIOSItems, $BIOSName, $BIOSVersion, $SMBIOSVersion
Dim $Item, $SerialNumber, $Manufacturer, $BIOSArray[4]
;$Computer = "."
$WMIService = GetObject("winmgmts:\\" + $Computer + "\root\cimv2")
$BIOSItems = $WMIService.ExecQuery( "Select * from Win32_BIOS where PrimaryBIOS = true", , 48 )
For Each $Item in $BIOSItems
$BIOSName = Trim($Item.Name)
$BIOSVersion = Trim($Item.Version)
$SMBIOSVersion = Trim($Item.SMBIOSBIOSVersion)
$SerialNumber = Trim($Item.SerialNumber)
$Manufacturer = Trim($Item.Manufacturer)
Next
$BIOSArray[0]=$BIOSName $BIOSArray[1]=$BIOSVersion $BIOSArray[2]=$SMBIOSVersion $BIOSArray[3]=$SerialNumber
$BIOSArray[4]=$Manufacturer
$GetBIOSInfo=$BIOSArray
EndFunction