Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

get multiple wmi objects one query

1,270 views
Skip to first unread message

attrib75

unread,
May 21, 2009, 12:29:01 PM5/21/09
to
Can you get more than one win32 type from a single get-wmiobject query?
I've tried all of the ways I could think of:

qwmi win32_logicaldisk, win32_computersystem doesn't work

gwmi (win32_logicaldisk, win32_computersystem) doesn't work

etc

how would you format that?

thanks!

Vadims Podans [MVP]

unread,
May 21, 2009, 1:26:31 PM5/21/09
to
you cannot do this. At one time you can query only one WMI class with
Get-WmiObject.
--
WBR, Vadims Podans
MVP: PowerShell
PowerShell blog - www.sysadmins.lv

"attrib75" <attr...@discussions.microsoft.com> rakstīja ziņojumā
"news:04902B2B-A4B5-4855...@microsoft.com"...

attrib75

unread,
May 21, 2009, 4:34:51 PM5/21/09
to

AWW :(

Thanks for replying. So you would have to write

"gwmi win32_logicaldisk, gwmi win32_computersystem" like that?

Could you do some for of for each loop or for each object?

tojo2000

unread,
May 21, 2009, 8:17:52 PM5/21/09
to
On May 21, 1:34 pm, attrib75 <attri...@discussions.microsoft.com>
wrote:

> AWW :(
>
> Thanks for replying.  So you would have to write
>
> "gwmi win32_logicaldisk, gwmi win32_computersystem" like that?
>
> Could you do some for of for each loop or for each object?
>
>
>
> "Vadims Podans [MVP]" wrote:
> > you cannot do this. At one time you can query only one WMI class with
> > Get-WmiObject.
> > --
> > WBR, Vadims Podans
> > MVP: PowerShell
> > PowerShell blog -www.sysadmins.lv
>
> > "attrib75" <attri...@discussions.microsoft.com> rakstīja ziņojumā

> > "news:04902B2B-A4B5-4855...@microsoft.com"...
> > > Can you get more than one win32 type  from a single get-wmiobject query?
> > > I've tried all of the ways I could think of:
>
> > > qwmi win32_logicaldisk, win32_computersystem  doesn't work
>
> > > gwmi (win32_logicaldisk, win32_computersystem)  doesn't work
>
> > > etc
>
> > > how would you format  that?
>
> > > thanks!

What is the output you're trying to get, and why are you trying to do
it in one query?

Vadims Podans [MVP]

unread,
May 22, 2009, 2:50:13 AM5/22/09
to
Get-WmiObject returns collection of identical objects. You cannot return
collection of 2 different object types with single Get-WmiObject query. You
should use any type of loop to get it (foreach or foreach-object)

--
WBR, Vadims Podans
MVP: PowerShell
PowerShell blog - www.sysadmins.lv

"attrib75" <attr...@discussions.microsoft.com> rakstīja ziņojumā
"news:97CFB701-66DA-40C7...@microsoft.com"...

0 new messages