Re: WMI Script to find resource ID



Hi

First - it seems like you have incorrect formating of the dashes around the GUIDID variable, next you run a ExecQuery that potentially will return more than one instance so you have to do a for loop to parse each returned object (even though you are know that only one instance will be returned). And finally, while parsing though this list you will have a object and will have to refer to the property of it. Try replacing your ResourceNO= and Wscript.Echo lines with these:

Set objResources = objSWbemServices.ExecQuery ("SELECT * FROM SMS_R_System WHERE SMSUniqueIdentifier='" & GUIDID & "'")
For Each objResources In objResources
Wscript.Echo objResource.ResourceID
Next

Rgds,
Rune


"Ann Thomas" <anne_27@xxxxxxxxxxx> wrote in message news:1167752791.215197.94210@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hello

I am attempting a script that will read GUIDs from a log file and
connect to the SMS namespace and write the ResourceID based on the
client GUID to a text file

Here is what the script looks like - logstr1.txt is the file that has
the GUID -one on each line. I can't get this to work .. would
appreciate any ideas or suggestions.
Here is what logstr1.txt look like
79692D09-64F7-47E6-A9E5-7A9DF59E747B
1F692082-765D-4F7E-A115-0604D12FE498
6C724717-2754-48F9-9F1B-E42DAA44C418


On Error Resume Next

Set loc = CreateObject("WbemScripting.SWbemLocator")
Set objWbemServices = loc.ConnectServer( , "root\SMS\site_CEN")


Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("D:\temp\logstr1.txt")

Do Until objFile.AtEndOfStream
GUIDID= "GUID:" + objFile.ReadLine

ResourceNo=objSWbemServices.ExecQuery ("SELECT ResourceID FROM
SMS_R_System WHERE SMSUniqueIdentifier="'" & GUIDID & "'" ")

Wscript.Echo ResourceNo

Loop


.