Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - WMI script to obtain Power Supply information

Reply
 
Old 06-09-2009   #1 (permalink)
Nelson


 
 

WMI script to obtain Power Supply information

I am writting a server inventory database and using WMI VBScripts to obtain
the data. So far I have been able to easily get RAM, CPU, Model, etc.
information using WMI. I am now trying to collect the total number of powers
supplies in a server. For example a HP DL380 G5 might have 1 or 2 power
supplies installed in it.

I cannot find any information (Google, Bing, etc.) regarding how to get this
information. I found Win32_PowerSupply but Google only yields one hit. When
I try to use this class, it errors out. Here is a tidbit of the code:

For Each objItem in objDictionary
Set objWMIService = GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & objDictionary.Item(objItem) &
"\root\cimv2")
Set colPowerSupply = objWMIService.ExecQuery("Select * from
Win32_PowerSupply")
For Each objPS in colPowerSupply
objResultsFile.WriteLine(objDictionary.Item(objItem) & "," & objPS.Name)
Next
Next

It basically fails at the "For Each objPS in colPowerSupply" line.

Anyone have any ideas how to get this information? Is it stored in the
registry maybe and I can query that instead? Trying to Google this has been
a nightmare compared to how easy it was to find sample scripts on other
inventory gathering techniques.

Thanks
Nelson

My System SpecsSystem Spec
Old 06-09-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: WMI script to obtain Power Supply information


"Nelson" <Nelson@xxxxxx> wrote in message
news:B0B1E290-4687-4F94-A470-A1F23D03EC84@xxxxxx
Quote:

>I am writting a server inventory database and using WMI VBScripts to obtain
> the data. So far I have been able to easily get RAM, CPU, Model, etc.
> information using WMI. I am now trying to collect the total number of
> powers
> supplies in a server. For example a HP DL380 G5 might have 1 or 2 power
> supplies installed in it.
>
> I cannot find any information (Google, Bing, etc.) regarding how to get
> this
> information. I found Win32_PowerSupply but Google only yields one hit.
> When
> I try to use this class, it errors out. Here is a tidbit of the code:
>
> For Each objItem in objDictionary
> Set objWMIService = GetObject("winmgmts:" &
> "{impersonationLevel=impersonate}!\\" & objDictionary.Item(objItem) &
> "\root\cimv2")
> Set colPowerSupply = objWMIService.ExecQuery("Select * from
> Win32_PowerSupply")
> For Each objPS in colPowerSupply
> objResultsFile.WriteLine(objDictionary.Item(objItem) & "," & objPS.Name)
> Next
> Next
>
> It basically fails at the "For Each objPS in colPowerSupply" line.
>
> Anyone have any ideas how to get this information? Is it stored in the
> registry maybe and I can query that instead? Trying to Google this has
> been
> a nightmare compared to how easy it was to find sample scripts on other
> inventory gathering techniques.
>
> Thanks
> Nelson
I cannot find a machine where the Win32_PowerSupply class is supported.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 06-09-2009   #3 (permalink)
OldDog


 
 

Re: WMI script to obtain Power Supply information

On Jun 9, 2:34*pm, David Kerber
<ns_dkerber@xxxxxx_WarrenRogersAssociates.com> wrote:
Quote:

> In article <e4ND#eT6JHA.1...@xxxxxx>, rlmueller-
> nos...@xxxxxx says...
>
> ...
>
Quote:
Quote:

> > > It basically fails at the "For Each objPS in colPowerSupply" line.
>
Quote:
Quote:

> > > Anyone have any ideas how to get this information? *Is it stored inthe
> > > registry maybe and I can query that instead? *Trying to Google thishas
> > > been
> > > a nightmare compared to how easy it was to find sample scripts on other
> > > inventory gathering techniques.
>
Quote:
Quote:

> > > Thanks
> > > Nelson
>
Quote:

> > I cannot find a machine where the Win32_PowerSupply class is supported.
>
> I would be shocked if windows tracked (or could even get) information
> about power supplies. *If it is available in some machines, it's almost
> certainly mfr's speciial hardware management software that is providing
> it.
>
> --
> /~\ The ASCII
> \ / Ribbon Campaign
> *X *Against HTML
> / \ Email!
>
> Remove the ns_ from if replying by e-mail (but keep posts in the
> newsgroups if possible).
I just ran across something that I found interesting.
If you use HP/Compaq servers and you have installed the Management
agents,
You will find a Name Space called root\HPQ that has 363 classes
associated with it.

Basically, every thing the HP Management agents know about the server
is available.

This might be of use to you

OldDog
My System SpecsSystem Spec
Old 06-09-2009   #4 (permalink)
Nelson


 
 

Re: WMI script to obtain Power Supply information

Excellent. Thanks to all three of you for taking the time to reply.

Nelson

"OldDog" wrote:
Quote:

> On Jun 9, 2:34 pm, David Kerber
> <ns_dkerber@xxxxxx_WarrenRogersAssociates.com> wrote:
Quote:

> > In article <e4ND#eT6JHA.1...@xxxxxx>, rlmueller-
> > nos...@xxxxxx says...
> >
> > ...
> >
Quote:

> > > > It basically fails at the "For Each objPS in colPowerSupply" line.
> >
Quote:

> > > > Anyone have any ideas how to get this information? Is it stored in the
> > > > registry maybe and I can query that instead? Trying to Google this has
> > > > been
> > > > a nightmare compared to how easy it was to find sample scripts on other
> > > > inventory gathering techniques.
> >
Quote:

> > > > Thanks
> > > > Nelson
> >
Quote:

> > > I cannot find a machine where the Win32_PowerSupply class is supported.
> >
> > I would be shocked if windows tracked (or could even get) information
> > about power supplies. If it is available in some machines, it's almost
> > certainly mfr's speciial hardware management software that is providing
> > it.
> >
> > --
> > /~\ The ASCII
> > \ / Ribbon Campaign
> > X Against HTML
> > / \ Email!
> >
> > Remove the ns_ from if replying by e-mail (but keep posts in the
> > newsgroups if possible).
>
> I just ran across something that I found interesting.
> If you use HP/Compaq servers and you have installed the Management
> agents,
> You will find a Name Space called root\HPQ that has 363 classes
> associated with it.
>
> Basically, every thing the HP Management agents know about the server
> is available.
>
> This might be of use to you
>
> OldDog
>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Power supply help Software
Need new power supply General Discussion
power supply General Discussion
Bad Power Supply Vista installation & setup
Power Supply - Request for information General Discussion


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

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