Can you change or add row?

So i have variable called $runcounter. Below was the result when I executed the variable. How should I rename/add/modify rows inside of the variables? Example, I want to rename or add rows to something easy to understand and round off the Values?

PS C:\Users\abc> $runcounter

Counter                                                              InstanceName                   Value
-------                                                              ------------                   -----
\\comps\processor(_total)\% processor time                 _total              5.86140015920504
\\comps\memory\available mbytes                                                            4532
\\comps\paging file(_total)\% usage                        _total              10.7064565022786
\\comps\logicaldisk(c:)\avg. disk bytes/read               c:                              6144
\\comps\logicaldisk(harddiskvolume4)\avg. disk bytes/read  harddiskvolume4                    0
\\comps\logicaldisk(_total)\avg. disk bytes/read           _total                          6144
\\comps\logicaldisk(c:)\avg. disk bytes/write              c:                  12580.5714285714
\\comps\logicaldisk(harddiskvolume4)\avg. disk bytes/write harddiskvolume4                    0
\\comps\logicaldisk(_total)\avg. disk bytes/write          _total              12580.5714285714
\\comps\logicaldisk(c:)\avg. disk sec/read                 c:                         0.0001995
\\comps\logicaldisk(harddiskvolume4)\avg. disk sec/read    harddiskvolume4                    0
\\comps\logicaldisk(_total)\avg. disk sec/read             _total                     0.0001995
\\comps\logicaldisk(c:)\avg. disk sec/write                c:              0.000339507142857143
\\comps\logicaldisk(harddiskvolume4)\avg. disk sec/write   harddiskvolume4                    0
\\comps\logicaldisk(_total)\avg. disk sec/write            _total          0.000339507142857143
\\comps\logicaldisk(c:)\disk read bytes/sec                c:                  12270.7865406408
\\comps\logicaldisk(harddiskvolume4)\disk read bytes/sec   harddiskvolume4                    0
\\comps\logicaldisk(_total)\disk read bytes/sec            _total              12270.7865406408
\\comps\logicaldisk(c:)\disk write bytes/sec               c:                  175881.273749185
\\comps\logicaldisk(harddiskvolume4)\disk write bytes/sec  harddiskvolume4                    0
\\comps\logicaldisk(_total)\disk write bytes/sec           _total              175881.273749185
\\comps\logicaldisk(c:)\disk reads/sec                     c:                  1.99719833018242
\\comps\logicaldisk(harddiskvolume4)\disk reads/sec        harddiskvolume4                    0
\\comps\logicaldisk(_total)\disk reads/sec                 _total              1.99719833018242
\\comps\logicaldisk(c:)\disk writes/sec                    c:                  13.9803883112769
\\comps\logicaldisk(harddiskvolume4)\disk writes/sec       harddiskvolume4                    0
\\comps\logicaldisk(_total)\disk writes/sec                _total              13.9803883112769

Check out calculated properties:

Using PowerShell’s Calculated Properties – Microsoft Certified Professional Magazine Online (mcpmag.com)

To round a number you can use the dot net method .Round() of the class [Math]

[Math]::Round(7.45158796670692,2)

I have modified my post a bit. How about the rows? and in the variable already.

When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to help you making their work twice or more.

Thanks

Are you unsatisfied with the answers you’ve got so far?

Yes. looks like the calculated properties was for headers or columns. I was looking to change the rows.

It is to change the rows. Have you even tried? If something is unclear you could ask further questions?! :man_shrugging:t4:

Here’s an example:

$runcounter |
    Select-Object -Property *,@{
        Name = 'RoundedValue'
        Expression = {[Math]::Round($_.Value,2)}
    }

Apologies Olaf, Example from the output “\comps\processor(_total)% processor time”, I want to change this into simply “CPU Usage” and “\comps\memory\available mbytes” into simply “Memory Usage” …including the rest.

Take a look at the example I added to my last reply. You can put almost anything you like to the Expression script block. But it might be very cumbersome when you want to change each and every single cell of the column Counter individually. :man_shrugging:t4:

Your example let me change the header Value to RoundedValue and also rounded their values. My biggest problem was the data under header Counter. I don’t want to change the header Counter but its data itself. I want to rename it. I just cant figure it out. All my test/code are failing to change it.

This help was now solved after recommendation from Reddit user to use Switch Statement