Pinball
Enthusiast
Enthusiast

Cluster Capacity script

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
AGerlitz
Contributor
Contributor

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.

View solution in original post

0 Kudos
4 Replies
AGerlitz
Contributor
Contributor

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.

0 Kudos
Pinball
Enthusiast
Enthusiast

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

0 Kudos
AGerlitz
Contributor
Contributor

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.

0 Kudos
Pinball
Enthusiast
Enthusiast

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

0 Kudos