Home All Groups Group Topic Archive Search About

How can I do a WMI Bulk data retrieval ?

Author
20 Nov 2008 10:08 AM
SherTeks
Hi,

The following WMI query executes fine and outputs the Processor details

On Error Resume Next

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")

For Each objItem in colItems
    Wscript.Echo "Address Width: " & objItem.AddressWidth
    Wscript.Echo "Architecture: " & objItem.Architecture
    Wscript.Echo "Availability: " & objItem.Availability
    Wscript.Echo "CPU Status: " & objItem.CpuStatus
Next

Now, I also want to execute the below query

Set colBIOS = objWMIService.ExecQuery _
    ("Select * from Win32_BIOS")

which would get BIOS details.

But, how can I execute both the query in one fell swoop ie. in a bulk.

Note : There is some snmp (protocol) command called snmpbulkget that
actually fetches bulk data from a network entiry
with one command. Is there anything similar to this in WMI that fetches bulk
data.

Thanks in Advance

Author
20 Nov 2008 10:41 AM
Pegasus (MVP)
Show quote Hide quote
"SherTeks" <SherT***@discussions.microsoft.com> wrote in message
news:6D254F68-839B-4F91-89A9-5C4C4AF9FA0C@microsoft.com...
> Hi,
>
> The following WMI query executes fine and outputs the Processor details
>
> On Error Resume Next
>
> strComputer = "."
> Set objWMIService = GetObject("winmgmts:" _
>    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
>
> Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
>
> For Each objItem in colItems
>    Wscript.Echo "Address Width: " & objItem.AddressWidth
>    Wscript.Echo "Architecture: " & objItem.Architecture
>    Wscript.Echo "Availability: " & objItem.Availability
>    Wscript.Echo "CPU Status: " & objItem.CpuStatus
> Next
>
> Now, I also want to execute the below query
>
> Set colBIOS = objWMIService.ExecQuery _
>    ("Select * from Win32_BIOS")
>
> which would get BIOS details.
>
> But, how can I execute both the query in one fell swoop ie. in a bulk.
>
> Note : There is some snmp (protocol) command called snmpbulkget that
> actually fetches bulk data from a network entiry
> with one command. Is there anything similar to this in WMI that fetches
> bulk
> data.
>
> Thanks in Advance

Maybe I'm missin the point in your question but why don't you simply
continue along the same lines in your code?

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")

For Each objItem In colItems
    WScript.Echo "Address Width: " & objItem.AddressWidth
    WScript.Echo "Architecture: " & objItem.Architecture
    WScript.Echo "Availability: " & objItem.Availability
    WScript.Echo "CPU Status: " & objItem.CpuStatus
Next

Set colBIOS = objWMIService.ExecQuery _
    ("Select * from Win32_BIOS")

For Each objItem In colBIOS
WScript.Echo "BIOS Manufacturer: " & objItem.Manufacturer
WScript.Echo "BIOS Details:"
For i = 0 To UBound(objItem.BIOSVersion)
  WScript.Echo "  " & objItem.BIOSVersion(i)
Next
Next
Author
20 Nov 2008 12:06 PM
SherTeks
Show quote Hide quote
"Pegasus (MVP)" wrote:

>
> "SherTeks" <SherT***@discussions.microsoft.com> wrote in message
> news:6D254F68-839B-4F91-89A9-5C4C4AF9FA0C@microsoft.com...
> > Hi,
> >
> > The following WMI query executes fine and outputs the Processor details
> >
> > On Error Resume Next
> >
> > strComputer = "."
> > Set objWMIService = GetObject("winmgmts:" _
> >    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
> >
> > Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
> >
> > For Each objItem in colItems
> >    Wscript.Echo "Address Width: " & objItem.AddressWidth
> >    Wscript.Echo "Architecture: " & objItem.Architecture
> >    Wscript.Echo "Availability: " & objItem.Availability
> >    Wscript.Echo "CPU Status: " & objItem.CpuStatus
> > Next
> >
> > Now, I also want to execute the below query
> >
> > Set colBIOS = objWMIService.ExecQuery _
> >    ("Select * from Win32_BIOS")
> >
> > which would get BIOS details.
> >
> > But, how can I execute both the query in one fell swoop ie. in a bulk.
> >
> > Note : There is some snmp (protocol) command called snmpbulkget that
> > actually fetches bulk data from a network entiry
> > with one command. Is there anything similar to this in WMI that fetches
> > bulk
> > data.
> >
> > Thanks in Advance
>
> Maybe I'm missin the point in your question but why don't you simply
> continue along the same lines in your code?
>
> Set objWMIService = GetObject("winmgmts:" _
>     & "{impersonationLevel=impersonate}!\\.\root\cimv2")
> Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
>
> For Each objItem In colItems
>     WScript.Echo "Address Width: " & objItem.AddressWidth
>     WScript.Echo "Architecture: " & objItem.Architecture
>     WScript.Echo "Availability: " & objItem.Availability
>     WScript.Echo "CPU Status: " & objItem.CpuStatus
> Next
>
> Set colBIOS = objWMIService.ExecQuery _
>     ("Select * from Win32_BIOS")
>
> For Each objItem In colBIOS
>  WScript.Echo "BIOS Manufacturer: " & objItem.Manufacturer
>  WScript.Echo "BIOS Details:"
>  For i = 0 To UBound(objItem.BIOSVersion)
>   WScript.Echo "  " & objItem.BIOSVersion(i)
>  Next
> Next
>
>
> Hi,

Thanks for the reply.
Yes, I knew this could be done.
But, I was looking for some other way (or some other WMI query) which would
actually package more than one queries ie. no more multiple ExecQuery(..) or
For loops.

May be some WMI query which works like snmpbulkget command which actually
gets all available details and the required details could be later parsed.

Thanks again.
Author
20 Nov 2008 12:55 PM
Pegasus (MVP)
Show quote Hide quote
"SherTeks" <SherT***@discussions.microsoft.com> wrote in message
news:24440D9D-CB44-4BAB-8E16-24D402FF3E9F@microsoft.com...
>
>
> "Pegasus (MVP)" wrote:
>
>>
>> "SherTeks" <SherT***@discussions.microsoft.com> wrote in message
>> news:6D254F68-839B-4F91-89A9-5C4C4AF9FA0C@microsoft.com...
>> > Hi,
>> >
>> > The following WMI query executes fine and outputs the Processor details
>> >
>> > On Error Resume Next
>> >
>> > strComputer = "."
>> > Set objWMIService = GetObject("winmgmts:" _
>> >    & "{impersonationLevel=impersonate}!\\" & strComputer &
>> > "\root\cimv2")
>> >
>> > Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
>> >
>> > For Each objItem in colItems
>> >    Wscript.Echo "Address Width: " & objItem.AddressWidth
>> >    Wscript.Echo "Architecture: " & objItem.Architecture
>> >    Wscript.Echo "Availability: " & objItem.Availability
>> >    Wscript.Echo "CPU Status: " & objItem.CpuStatus
>> > Next
>> >
>> > Now, I also want to execute the below query
>> >
>> > Set colBIOS = objWMIService.ExecQuery _
>> >    ("Select * from Win32_BIOS")
>> >
>> > which would get BIOS details.
>> >
>> > But, how can I execute both the query in one fell swoop ie. in a bulk.
>> >
>> > Note : There is some snmp (protocol) command called snmpbulkget that
>> > actually fetches bulk data from a network entiry
>> > with one command. Is there anything similar to this in WMI that fetches
>> > bulk
>> > data.
>> >
>> > Thanks in Advance
>>
>> Maybe I'm missin the point in your question but why don't you simply
>> continue along the same lines in your code?
>>
>> Set objWMIService = GetObject("winmgmts:" _
>>     & "{impersonationLevel=impersonate}!\\.\root\cimv2")
>> Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
>>
>> For Each objItem In colItems
>>     WScript.Echo "Address Width: " & objItem.AddressWidth
>>     WScript.Echo "Architecture: " & objItem.Architecture
>>     WScript.Echo "Availability: " & objItem.Availability
>>     WScript.Echo "CPU Status: " & objItem.CpuStatus
>> Next
>>
>> Set colBIOS = objWMIService.ExecQuery _
>>     ("Select * from Win32_BIOS")
>>
>> For Each objItem In colBIOS
>>  WScript.Echo "BIOS Manufacturer: " & objItem.Manufacturer
>>  WScript.Echo "BIOS Details:"
>>  For i = 0 To UBound(objItem.BIOSVersion)
>>   WScript.Echo "  " & objItem.BIOSVersion(i)
>>  Next
>> Next
>>
>>
>> Hi,
>
> Thanks for the reply.
> Yes, I knew this could be done.
> But, I was looking for some other way (or some other WMI query) which
> would
> actually package more than one queries ie. no more multiple ExecQuery(..)
> or
> For loops.
>
> May be some WMI query which works like snmpbulkget command which actually
> gets all available details and the required details could be later parsed.
>
> Thanks again.

It's very foggy today in the place where I live and maybe my brain is fogged
up too but I can't see the purpose of your efforts. What's wrong with first
dealing with the Win32_Processor details, perhaps storing them in a
temporary array, then moving on to the BIOS staff, again storing it in a
suitable place? The corresponding pseudo-code would look like so:

Get_Processor_Details
Get_BIOS_Details
Compile_output_report
Author
20 Nov 2008 4:32 PM
Richard Mueller [MVP]
Show quote Hide quote
"SherTeks" <SherT***@discussions.microsoft.com> wrote in message
news:24440D9D-CB44-4BAB-8E16-24D402FF3E9F@microsoft.com...
>
>
> "Pegasus (MVP)" wrote:
>
>>
>> "SherTeks" <SherT***@discussions.microsoft.com> wrote in message
>> news:6D254F68-839B-4F91-89A9-5C4C4AF9FA0C@microsoft.com...
>> > Hi,
>> >
>> > The following WMI query executes fine and outputs the Processor details
>> >
>> > On Error Resume Next
>> >
>> > strComputer = "."
>> > Set objWMIService = GetObject("winmgmts:" _
>> >    & "{impersonationLevel=impersonate}!\\" & strComputer &
>> > "\root\cimv2")
>> >
>> > Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
>> >
>> > For Each objItem in colItems
>> >    Wscript.Echo "Address Width: " & objItem.AddressWidth
>> >    Wscript.Echo "Architecture: " & objItem.Architecture
>> >    Wscript.Echo "Availability: " & objItem.Availability
>> >    Wscript.Echo "CPU Status: " & objItem.CpuStatus
>> > Next
>> >
>> > Now, I also want to execute the below query
>> >
>> > Set colBIOS = objWMIService.ExecQuery _
>> >    ("Select * from Win32_BIOS")
>> >
>> > which would get BIOS details.
>> >
>> > But, how can I execute both the query in one fell swoop ie. in a bulk.
>> >
>> > Note : There is some snmp (protocol) command called snmpbulkget that
>> > actually fetches bulk data from a network entiry
>> > with one command. Is there anything similar to this in WMI that fetches
>> > bulk
>> > data.
>> >
>> > Thanks in Advance
>>
>> Maybe I'm missin the point in your question but why don't you simply
>> continue along the same lines in your code?
>>
>> Set objWMIService = GetObject("winmgmts:" _
>>     & "{impersonationLevel=impersonate}!\\.\root\cimv2")
>> Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
>>
>> For Each objItem In colItems
>>     WScript.Echo "Address Width: " & objItem.AddressWidth
>>     WScript.Echo "Architecture: " & objItem.Architecture
>>     WScript.Echo "Availability: " & objItem.Availability
>>     WScript.Echo "CPU Status: " & objItem.CpuStatus
>> Next
>>
>> Set colBIOS = objWMIService.ExecQuery _
>>     ("Select * from Win32_BIOS")
>>
>> For Each objItem In colBIOS
>>  WScript.Echo "BIOS Manufacturer: " & objItem.Manufacturer
>>  WScript.Echo "BIOS Details:"
>>  For i = 0 To UBound(objItem.BIOSVersion)
>>   WScript.Echo "  " & objItem.BIOSVersion(i)
>>  Next
>> Next
>>
>>
>> Hi,
>
> Thanks for the reply.
> Yes, I knew this could be done.
> But, I was looking for some other way (or some other WMI query) which
> would
> actually package more than one queries ie. no more multiple ExecQuery(..)
> or
> For loops.
>
> May be some WMI query which works like snmpbulkget command which actually
> gets all available details and the required details could be later parsed.
>
> Thanks again.

There is no more efficient way to retrieve the information. I know of no way
to combine the queries.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--
Author
21 Nov 2008 4:37 AM
SherTeks
Show quote Hide quote
"Richard Mueller [MVP]" wrote:

>
> "SherTeks" <SherT***@discussions.microsoft.com> wrote in message
> news:24440D9D-CB44-4BAB-8E16-24D402FF3E9F@microsoft.com...
> >
> >
> > "Pegasus (MVP)" wrote:
> >
> >>
> >> "SherTeks" <SherT***@discussions.microsoft.com> wrote in message
> >> news:6D254F68-839B-4F91-89A9-5C4C4AF9FA0C@microsoft.com...
> >> > Hi,
> >> >
> >> > The following WMI query executes fine and outputs the Processor details
> >> >
> >> > On Error Resume Next
> >> >
> >> > strComputer = "."
> >> > Set objWMIService = GetObject("winmgmts:" _
> >> >    & "{impersonationLevel=impersonate}!\\" & strComputer &
> >> > "\root\cimv2")
> >> >
> >> > Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
> >> >
> >> > For Each objItem in colItems
> >> >    Wscript.Echo "Address Width: " & objItem.AddressWidth
> >> >    Wscript.Echo "Architecture: " & objItem.Architecture
> >> >    Wscript.Echo "Availability: " & objItem.Availability
> >> >    Wscript.Echo "CPU Status: " & objItem.CpuStatus
> >> > Next
> >> >
> >> > Now, I also want to execute the below query
> >> >
> >> > Set colBIOS = objWMIService.ExecQuery _
> >> >    ("Select * from Win32_BIOS")
> >> >
> >> > which would get BIOS details.
> >> >
> >> > But, how can I execute both the query in one fell swoop ie. in a bulk.
> >> >
> >> > Note : There is some snmp (protocol) command called snmpbulkget that
> >> > actually fetches bulk data from a network entiry
> >> > with one command. Is there anything similar to this in WMI that fetches
> >> > bulk
> >> > data.
> >> >
> >> > Thanks in Advance
> >>
> >> Maybe I'm missin the point in your question but why don't you simply
> >> continue along the same lines in your code?
> >>
> >> Set objWMIService = GetObject("winmgmts:" _
> >>     & "{impersonationLevel=impersonate}!\\.\root\cimv2")
> >> Set colItems = objWMIService.ExecQuery("Select * from Win32_Processor")
> >>
> >> For Each objItem In colItems
> >>     WScript.Echo "Address Width: " & objItem.AddressWidth
> >>     WScript.Echo "Architecture: " & objItem.Architecture
> >>     WScript.Echo "Availability: " & objItem.Availability
> >>     WScript.Echo "CPU Status: " & objItem.CpuStatus
> >> Next
> >>
> >> Set colBIOS = objWMIService.ExecQuery _
> >>     ("Select * from Win32_BIOS")
> >>
> >> For Each objItem In colBIOS
> >>  WScript.Echo "BIOS Manufacturer: " & objItem.Manufacturer
> >>  WScript.Echo "BIOS Details:"
> >>  For i = 0 To UBound(objItem.BIOSVersion)
> >>   WScript.Echo "  " & objItem.BIOSVersion(i)
> >>  Next
> >> Next
> >>
> >>
> >> Hi,
> >
> > Thanks for the reply.
> > Yes, I knew this could be done.
> > But, I was looking for some other way (or some other WMI query) which
> > would
> > actually package more than one queries ie. no more multiple ExecQuery(..)
> > or
> > For loops.
> >
> > May be some WMI query which works like snmpbulkget command which actually
> > gets all available details and the required details could be later parsed.
> >
> > Thanks again.
>
> There is no more efficient way to retrieve the information. I know of no way
> to combine the queries.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab - http://www.rlmueller.net
> --
>
>
>

Thanks all for the replies