View Only
  • 1.  Get-Stat for the last week is null

    Posted Nov 15, 2018 09:13 PM

    For some reason, my get-stat is coming up null for the last week and I am not sure what is going on. vCenter and Hosts were just patched and rebooted as well.

    Realtime is fine

    get-stat -stat mem.usage.average -entity $vm -realtime

    Just the normal command is fine.......but it only displays stuff from last month and before.....which I thought was odd

    get-stat -stat mem.usage.average -entity $vm

    But when I try to do last 7 days it is null

    get-stat -stat mem.usage.average -entity $vm  -start (get-date).adddays(-7) -finish (get-date) |GM

    I use this same script several other places and it all works fine, I am just trying to figure out what might this different.


  • 2.  RE: Get-Stat for the last week is null

    Posted Nov 15, 2018 10:02 PM

    Looks like the aggregation jobs on the vCenter might be failing.
    Are you running a VCSA or vCenter on a Windows server?

  • 3.  RE: Get-Stat for the last week is null

    Posted Nov 16, 2018 04:12 PM

    LucD   It is a windows vCenter

    I haven't found anything googling how to fix potential aggregation jobs.. Thoughts?

  • 4.  RE: Get-Stat for the last week is null
    Best Answer

    Posted Nov 16, 2018 04:46 PM

    I assume in that case you are using a SQL Server DB in that case?

    If yes, you can use the SQL Enterprise Manager to check the status of the scheduled jobs marked with 'Stats Rollup'
    I suspect something might be wrong with at least one of those jobs.

    As an alternative, you can use a function from the PowerCLI Reference book.

    function Get-AggregationJob {


    .SYNOPSIS Returns the SQL jobs that perform vCenter statistical data aggregation

    .DESCRIPTION The function takes all SQL jobs in the “Stats Rollup” category and returns key data for each of the jobs


       Source: Automating vSphere Administration

       Authors: Luc Dekens, Jonathan Medd, Brian Graf, Alan Renouf, Glenn Sizemore, Andrew Sullivan

    .PARAMETER SqlServer Name of the SQL server where the vSphere database is hosted

    .EXAMPLE Get-AggregationJob ‘serverA’


        param( [parameter(mandatory = $true,

                 HelpMessage = 'Enter the name of the vCenter SQL server')]




        $SMO = ‘Microsoft.SqlServer.SMO’

        [System.Reflection.Assembly]::LoadWithPartialName($SMO) | Out-Null

        $SMOSrv = ‘Microsoft.SqlServer.Management.Smo.Server’

        $sqlSRv = New-Object ($SMOSrv) $sqlServer


        $sqlSrv.JobServer.Jobs | Where-Object {$.Category -eq 'Stats Rollup'} | Foreach-Object {

             $object = [ordered]@{

                  Name = $.Name

                  Description = $.Description

                  LastRun = $.LastRunDate

                  NextRun = $.NextRunDate

                  LastRunResult = $.LastRunOutcome

                  'Schedule(s)' = $.JobSchedules | %{$.Name}


             New-Object PSObject -Property $object