lmalave Posted November 9, 2016 Posted November 9, 2016 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,
lmalave Posted November 11, 2016 Author Posted November 11, 2016 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]}}");
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now