Hi there
I need some assistance in getting the correct syntax for line 61-63 in the attached script and getting the correct values for line 56-57 on a per cluster base.
i wish to remove the decimal for the results of line 61-63, i've added the (), 0 as per the other lines but i clearly fail to understand the correct positioning in this use case. For line 56-57 i'm trying to also get the details on a per cluster base for the previous day.
Hope someone got some recommendation and any other advice for improving the script.
Thanks
Johan
Sorry try putting the value part of those lines in parenthesis:
Add-Member -pass NoteProperty "ClusterCPUUsageAverage" ("{0:N1}" -f $stat.average) |
Let me know if that works for you.
What if you edit the Add-member lines as follows:
Add-Member -pass NoteProperty "ClusterCPUUsageAverage" "{0:N2}" -f $stat.average |
Add-Member -pass NoteProperty "ClusterCPUUsageMax" "{0:N2}" -f $stat.maximum |
Add-Member -pass NoteProperty "ClusterCPUUsageMin" "{0:N2}" -f $stat.minimum |
Change the 2 in "{0:N2}" to the number of decimal places you want to display.
Let me know if this works for you.
Hi tdpoakg
First thank you for the reply, unfortunately this doesn't seem to work. Below is the query error.
Add-Member : The SecondValue parameter is not necessary for a member of type "NoteProperty" and should not be specified. Do not specify
the SecondValue parameter when adding members of this type.
At C:\scripts\Get-Cluster-Usage-Stats.ps1:61 char:1
+ Add-Member -pass NoteProperty "ClusterCPUUsageAverage" "{0:N1}" -f $sta ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Add-Member], InvalidOperationException
+ FullyQualifiedErrorId : Value2ShouldNotBeSpecified,Microsoft.PowerShell.Commands.AddMemberCommand
Script Update:
Add-Member -pass NoteProperty "ClusterCPUUsageAverage" "{0:N1}" -f $stat.average |
Add-Member -pass NoteProperty "ClusterCPUUsageMax" "{0:N1}" -f $stat.maximum |
Add-Member -pass NoteProperty "ClusterCPUUsageMin" "{0:N1}" -f $stat.minimum |
Johan
Sorry try putting the value part of those lines in parenthesis:
Add-Member -pass NoteProperty "ClusterCPUUsageAverage" ("{0:N1}" -f $stat.average) |
Let me know if that works for you.
Hi again
Thank you very much, this solved the first problem for me, I'll open a new thread for the second part of the request,
Johan