Jump to content
Software FX Community

Dual wmi classes


Recommended Posts

My problem is that i want to have 2 wmiobjects in the same gauge

This one i want to be the main gauge

Get-WmiObject win32_Processor | out-gauge -value LoadPercentage -float -refresh 0:0:1

And this one i want to be a innergauge

 get-wmiobject Win32_Process | group-object -property group | out-gauge -value count -type digital -refresh 0:0:1

 

I know how to use same object with two diffrent values in a gauge but how do i use two diffrent objects in the same gauge?

BubbleChart1.zip

Link to comment
Share on other sites

This will get your started...  Copy and paste into your PSH session:

$val=Get-WmiObject win32_Processor|%{$_.loadpercentage}$val1=(get-wmiobject Win32_Process).countout-gauge -type digital -value $val -float -innergauges_add digital `-innergauges_0_digitalpanel_value $val1 -refresh 0:0:1

Only problem is that the -refresh will not work.  I think for it to work, the first 2 lines will have to be in a ps1 script.  Then they will have to pass their output to out-gauge.  Now, the complicated part might be that your trying to pass 2 values via a ps1 script, which you won't be able to do just by outputting a string.

You might actually have to pass *objects* to out-gauge so you can set your -value.  I don't know how to have a ps1 script output actual objects off the top of my head right now.

There might be another way that I can't think of right now...  I'll keep thinking about it unless someone else comes up with a solution.

Link to comment
Share on other sites

As always the key is first to come up with a script that returns the data you want in your gadget, in the following script I am using a powershell feature that allows you to add properties to any object.

Contents of DualProcData.ps1


$loadPerc = (get-wmiObject win32_Processor | measure-object -average LoadPercentage).Average
$procCount = (ps).Count
$obj = new-object system.object
add-member -inputobject $obj -membertype NoteProperty -Name LoadPercentage -value $loadPerc
add-member -inputobject $obj -membertype NoteProperty -Name ProcessCount -value $procCount
$obj

Note that I changed how you are getting the LoadPercentage so that it works in multi-proc systems, also I used ps instead of get-wmi to get the processes count.

Now you can use the fact that our gadgets support scriptblocks in many properties (read more here and here)

dualprocdata | out-gauge -value LoadPercentage -innergauges_add digital -innergauges_0_digitalpanel_value {$_.ProcessCount} -InnerGauges_0_Layout_Target AnchorPoint -InnerGauges_0_Layout_AnchorPoint 0,-0.6 -float -refresh 0:0:10

And before anybody complain about typing all this Posted Image, remember, copy and paste it in a ps1 file and you will never have to type it again

JuanC

Link to comment
Share on other sites

I was going down that same path. I couldn't get past the script block for the inner gauge.  I knew I was close.

Thanks.

Jeffery HicksSAPIEN Technologies - Scripting, Simplified. www.SAPIEN.comVBScript & Windows PowerShell Training - www.ScriptingTraining.com/classes.aspWindows PowerShell? - www.SAPIENPress.com/powershell.aspblog: http://blog.SAPIEN.comblog: http://jdhitsolutions.blogspot.com 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...