WMI Script to find resource ID



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

.



Relevant Pages

  • Re: WMI Script help
    ... Here is what the script looks like - logstr1.txt is the file that has ... the GUID -one on each line. ... Set loc = CreateObject ... ResourceNo=objSWbemServices.ExecQuery ("SELECT ResourceID FROM ...
    (microsoft.public.scripting.wsh)
  • WMI Script help
    ... Here is what the script looks like - logstr1.txt is the file that has ... the GUID -one on each line. ... Set loc = CreateObject ... ResourceNo=objSWbemServices.ExecQuery ("SELECT ResourceID FROM ...
    (microsoft.public.scripting.wsh)
  • Re: Prestaging RIS - produces wrong GUID
    ... retrieves the GUID it forced me to try pasting in the GUID - so I ... So I have forced the read script to use the MAC address as the source ... > ore refer to this article for the step by step if you are using ADSI to ... >> But if you look at the computer account properties on the RIS tab it says ...
    (microsoft.public.windows.server.active_directory)
  • Re: Batch Script to parse lines in text file
    ... comfortable in batch try this hybrid script ... ... My ultimate goal is to query a registry key, which lists GUID values ... echo %frienlyname% %version% ... This works fine collecting the first GUID value in this group, ...
    (microsoft.public.windows.server.scripting)
  • Re: Retrieving an objects GUID as a string from Active Directory
    ... Your script is using the .objectGUID property, but the example I posted uses the ... ..GUID property. ... ' Bind to initial object. ... Set IADsObject = GetObject ...
    (microsoft.public.windows.server.scripting)