PowerCLI

 View Only
  • 1.  calculate the average memory used

    Posted Jul 05, 2022 03:00 PM

    Script to calculate the average memory used in a given time. for example: period of 5 days. It's possible?



  • 2.  RE: calculate the average memory used

    Posted Jul 05, 2022 03:11 PM

    Yes, but remember that statistics are aggregated



  • 3.  RE: calculate the average memory used

    Posted Jul 07, 2022 02:57 PM

    Please, could you send an example of the script creation to calculate the memory used in a certain period?



  • 4.  RE: calculate the average memory used

    Posted Jul 07, 2022 03:50 PM

    Did you search this community?
    There are quite a few examples available, for example Solved: Re: Get VMs CPU and Memory Daily Usage - VMware Technology Network VMTN



  • 5.  RE: calculate the average memory used

    Posted Jul 11, 2022 05:35 PM

    Thanks for the tip.

    I'm trying to add a field with the information of the average in a certain period, in this script below:

    $report += Get-Folder -Name 'nome_da_pasta' | Get-VM |
    Select Name,MemoryGB,
    @{N='UsedMemoryGB';E={$_.ExtensionData.Summary.Quickstats.GuestMemoryUsage}}

    #$_.ExtensionData.Summary.Quickstats.GuestMemoryUsage
    }

    $report | Export-Csv -Path $log -NoTypeInformation -UseCulture

    if ((Get-Content $log) -ne $null)
    {
    Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin -erroraction silentlyContinue
    $msg = new-object Net.Mail.MailMessage
    $smtp = new-object Net.Mail.SmtpClient($smtpServer)
    $att = new-object Net.Mail.Attachment($log)
    $msg.From = $from
    $msg.To.Add($to)
    $msg.Subject = "[VCENTER] Relatório de consumo de recursos PRD - $data"
    $msg.Attachments.Add($att)
    $msg.IsBodyHTML = $true
    $body = @"
    Relatório de consumos de recursos PRD ON PREMISE por pasta na data de $data.


    "@
    $msg.body = $body
    $smtp = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
    $smtp.EnableSsl = $true
    $user = "AKIAWJ54FS3T366IGXWY"
    $password = "BH1Ko2CLzTE1oNBD5/FoWiTIuP5Jg7Z+ieUScKiuhntq"

    $smtp.Credentials = New-Object System.Net.NetworkCredential($user, $password);
    $smtp.Send($msg)
    }

    if (Test-Path $log)
    {
    Remove-Item $log -Force -ErrorAction: Ignore
    }

    }

    - but i'm not succeeding



  • 6.  RE: calculate the average memory used

    Posted Jul 11, 2022 05:39 PM

    How did you try to use the Get-Stat cmdlet?