VMware Cloud Community
Pinball
Enthusiast
Enthusiast
Jump to solution

Cluster Capacity script

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

Reply
0 Kudos
1 Solution

Accepted Solutions
AGerlitz
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
4 Replies
AGerlitz
Contributor
Contributor
Jump to solution

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.

Reply
0 Kudos
Pinball
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos
AGerlitz
Contributor
Contributor
Jump to solution

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.

Reply
0 Kudos
Pinball
Enthusiast
Enthusiast
Jump to solution

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

Reply
0 Kudos