OK, I have three seperate functions that I would like to combine into one. However, I need to find out the most effective way of using a Function to output three different string vaules.
For example, I have a function to find a MAC address, IP address and Dell Serial Number. How can these be outputed seperately?
Here is code exurpts that contain the three different functions that I want to merge together. Please help.
Something that comes to mind is merging the strings together with ';' delimters as seperators...then using the Split function to seperate them again after out of the function. Is there a more effective way?
V/r,
SPC Key
United States Army
For example, I have a function to find a MAC address, IP address and Dell Serial Number. How can these be outputed seperately?
Here is code exurpts that contain the three different functions that I want to merge together. Please help.
Code:
FUNCTION FindMAC(strComputer)
' Continue with script if error occures.
ON ERROR RESUME NEXT
' When strComputer does not equal blank (null), then strInput is true.
' Personnally, I have not figured this line of code out yet; therefore,
' I do not understand its purpose. It causes no harm; therefore, it stays.
IF strComputer <> "" THEN
strInput = TRUE
END IF
SET objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
IF objWMIservice IS NOTHING THEN
WRITE_CSV_LINE strComputer & ",Error: " & err.number & " Unable to bind to WMI on " & strComputer & " - DESCRIPTION NOT CHANGED - FINDMAC"
EXIT FUNCTION
ELSE
SET colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
' Search for MAC address. Once MAC is found, it is stored into the "Function" as a value.
FOR EACH objItem IN colItems
FindMAC = objItem.MACAddress
NEXT
END IF
CleanScriptFromMemory
END FUNCTION
FUNCTION FindIP(strComputer)
' Continue with script if error occures.
ON ERROR RESUME NEXT
SET objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
IF objWMIservice IS NOTHING THEN
WRITE_CSV_LINE strComputer & ",Error: " & err.number & " Unable to bind to WMI on " & strComputer & " - DESCRIPTION NOT CHANGED - FINDIP"
EXIT FUNCTION
ELSE
SET colNics = objWMIService.ExecQuery ("Select * From Win32_NetworkAdapter Where NetConnectionID = 'Local Area Connection'")
FOR EACH objNic IN colNics
SET colNicConfigs = objWMIService.ExecQuery ("ASSOCIATORS OF {Win32_NetworkAdapter.DeviceID='" & objNic.DeviceID & "'}" & _
" WHERE AssocClass=Win32_NetworkAdapterSetting")
FOR EACH objNicConfig IN colNicConfigs
FOR EACH strIPAddress IN objNicConfig.IPAddress
IF LEN(strIPAddress) =< 15 THEN
FindIP = strIPAddress
END IF
NEXT
NEXT
NEXT
END IF
CleanScriptFromMemory
END FUNCTION
FUNCTION FindSTN(strComputer)
ON ERROR RESUME NEXT
SET objWMIservice = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
IF objWMIservice IS NOTHING THEN
WRITE_CSV_LINE strComputer & ",Error: " & err.number & " Unable to bind to WMI on " & strComputer & " - DESCRIPTION NOT CHANGED - FINDSTN"
EXIT FUNCTION
ELSE
SET colitems = objWMIservice.ExecQuery("Select * from Win32_BIOS",,48)
FOR EACH objitem IN colitems
FindSTN = objitem.serialnumber
NEXT
END IF
CleanScriptFromMemory
END FUNCTION
Something that comes to mind is merging the strings together with ';' delimters as seperators...then using the Split function to seperate them again after out of the function. Is there a more effective way?
V/r,
SPC Key
United States Army