Windows Vista Tips

Windows Vista Tips > Newsgroups > Windows Server > Scripting > How can I do a WMI Bulk data retrieval ?

Reply
Thread Tools Display Modes

How can I do a WMI Bulk data retrieval ?

 
 
SherTeks
Guest
Posts: n/a

 
      11-20-2008
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
 
Reply With Quote
 
 
 
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      11-20-2008

"SherTeks" <> wrote in message
news:6D254F68-839B-4F91-89A9-...
> 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\cim v2")
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


 
Reply With Quote
 
SherTeks
Guest
Posts: n/a

 
      11-20-2008


"Pegasus (MVP)" wrote:

>
> "SherTeks" <> wrote in message
> news:6D254F68-839B-4F91-89A9-...
> > 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\cim v2")
> 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.
 
Reply With Quote
 
Pegasus \(MVP\)
Guest
Posts: n/a

 
      11-20-2008

"SherTeks" <> wrote in message
news:24440D9D-CB44-4BAB-8E16-...
>
>
> "Pegasus (MVP)" wrote:
>
>>
>> "SherTeks" <> wrote in message
>> news:6D254F68-839B-4F91-89A9-...
>> > 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\cim v2")
>> 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


 
Reply With Quote
 
Richard Mueller [MVP]
Guest
Posts: n/a

 
      11-20-2008

"SherTeks" <> wrote in message
news:24440D9D-CB44-4BAB-8E16-...
>
>
> "Pegasus (MVP)" wrote:
>
>>
>> "SherTeks" <> wrote in message
>> news:6D254F68-839B-4F91-89A9-...
>> > 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\cim v2")
>> 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
--


 
Reply With Quote
 
SherTeks
Guest
Posts: n/a

 
      11-21-2008


"Richard Mueller [MVP]" wrote:

>
> "SherTeks" <> wrote in message
> news:24440D9D-CB44-4BAB-8E16-...
> >
> >
> > "Pegasus (MVP)" wrote:
> >
> >>
> >> "SherTeks" <> wrote in message
> >> news:6D254F68-839B-4F91-89A9-...
> >> > 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\cim v2")
> >> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
data retrieval Walter Goldschmidt Windows Vista File Management 7 03-05-2009 01:08 AM
Strange IRP completions and corrupt data on bulk transfer Curtis Petersen Windows Vista Drivers 1 10-21-2008 02:19 PM
USB - send data using bulk pipe AssafT Windows Vista Drivers 1 07-15-2008 05:38 PM
Looking for sample user data for bulk import Jason C Active Directory 3 07-02-2008 07:37 AM
USB bulk and Delayed-Write Data Error lionel letoffet Windows Vista Drivers 0 07-01-2004 06:25 AM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59