1 Reply Latest reply on Aug 7, 2017 2:38 AM by LucD

    Percentage memory and cpu used

    antoniogemelli Novice

      Hello,

      I have this script where I can get some info from each VM,

      I would like to add:

       

      CPU assigned/used

      Memory assigned/used

       

       

      Get-VM |select Guest,NumCpu,MemoryMB,Host,UsedSpaceGB,ProvisionedSpaceGB,Name|Export-Csv -path “C:\Users\gemela\Hardware_info.csv” -NoTypeInformation

        • 1. Re: Percentage memory and cpu used
          LucD Guru

          This can be done in multiple ways. In fact that ration is the "usage" percentage for memory and CPU.
          I used two rather simple methods.

           

           

          Get-VM |

          select Guest,NumCpu,MemoryMB,Host,UsedSpaceGB,ProvisionedSpaceGB,Name,

              @{N='CPU ratio';E={"$(Get-Stat -Entity $_ -Stat cpu.usage.average -Realtime -MaxSamples 1 | select -ExpandProperty Value) %"}},

              @{N='Memory ratio';E={"{0:P}" -f ($_.ExtensionData.Summary.Quickstats.GuestMemoryUsage/$_.MemoryMB)}} |

          Export-Csv -path “C:\Users\gemela\Hardware_info.csv” -NoTypeInformation