It appears that there might be an issue with the -Finish parameter of the Get-Stat cmdlet in PowerCLI version 13.1/13.2. Upon transitioning to PowerCLI 13.1 (also tested with 13.2.1) on one of our management servers, our vSphere environment performance monitoring code ceased to function properly.
Upon debugging, it became evident that the Get-Stat cmdlet fails to return any results when the -Finish parameter is utilized. While omitting the -Finish parameter does yield correct results, it hinders our ability to narrow down the observation period as needed.
The following code performs flawlessly under PowerCLI 12.2.0 and 13.0.0 (validated by reverting to the previous versions), yet yields no results under PowerCLI 13.1.0/13.2.1.
We've observed that the Release Notes for PowerCLI 13.1.0 include the following information:
"The performance of the Get-Stat cmdlet has been improved for the instances when you use the Start parameter."
Considering this, we wonder if there might be a connection between this enhancement and the unexpected behavior we are currently experiencing. Any insights or suggestions on this matter would be greatly appreciated.
### CODE
$VMStatParameters = "mem.usage.average"
$entity = get-vm $vmName | Where-Object {($_.PowerState -eq "PoweredOn")}
$startDate = "01/12/2023"
$endDate = "01/01/2024"
Get-Stat -Entity $entity -Stat $VMStatParameters -Start $startDate -Finish $endDate