Jump to content

How to show only the values from Get-Counter \LogicalDisk(C:)\Avg. Disk sec/Write?


Recommended Posts

Posted

Hi All,

 

I have the following code that is working just fine.

 

[font=Consolas][size=2][font=Consolas][size=2]txtDiskActivity.Text = RunScript([/size][/font][/size][/font][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515]"Invoke-Command -ComputerName "[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] + txtPC.Text + [/size][/font][/size][/font][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515]" -ScriptBlock {Get-Counter -counter '\\LogicalDisk(C:)\\Avg. Disk sec/Write'}"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]);[/size][/font][/size][/font]

The output is the following (view attachment):

 

"\\PC\logicaldisk(c:\avg. disk sec/write :

0.000180439778201115"

 

What I would like is to show only the number values and not the string. I read on "cookvalue" but had no luck implementing it.

 

Any help is appreciate.

 

Regards,

DiskActivity.jpg

Posted

I was able to get it to work:

 

txtDiskActivity.Text = RunScript("Invoke-Command -ComputerName " + txtPC.Text + " -ScriptBlock {Get-Counter -counter '\\LogicalDisk(C:)\\Avg. Disk sec/Write' | Foreach-Object {$_.CounterSamples.CookedValue[0]}}");

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...