Created
May 6, 2021 19:26
-
-
Save wolruf/cdb60d704366cb1ef75453d78fbc9515 to your computer and use it in GitHub Desktop.
vSphere VM reports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$vserver = Read-Host -Prompt 'Enter vCenter Server FQDN or IP address' | |
$creds = get-credential | |
Connect-VIServer $vserver -Credential $creds | |
Get-VM | Select Name, VMHost, NumCpu, MemoryMB, ` | |
@{N="ProvisionedSpace (GB)"; E={[math]::Round($_.ProvisionedSpaceGB)}}, ` | |
@{N="UsedSpace (GB)"; E={[math]::Round($_.UsedSpaceGB)}}, ` | |
@{N="CPU Usage (Average), Mhz" ; E={[Math]::Round((($_ | Get-Stat -Stat cpu.usagemhz.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}}, ` | |
@{N="CPU Usage (Max), MHz" ; E={[Math]::Round((($_ | Get-Stat -Stat cpu.usagemhz.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Maximum).Maximum),2)}}, ` | |
@{N="MaxHostCpuMhz" ; E={$_.NumCpu * $_.VMHost.CpuTotalMhz / $_.VMHost.NumCpu}}, ` | |
@{N="Memory Usage (Average), %" ; E={[Math]::Round((($_ | Get-Stat -Stat mem.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} , ` | |
@{N="Memory Usage (Max), %" ; E={[Math]::Round((($_ | Get-Stat -Stat mem.usage.average -IntervalMins 5 | Measure-Object Value -Maximum).Maximum),2)}} , ` | |
@{N="Network Usage (Average), KBps" ; E={[Math]::Round((($_ | Get-Stat -Stat net.usage.average -Start (Get-Date).AddDays(-30) -IntervalMins 5 | Measure-Object Value -Average).Average),2)}} |` | |
Export-Csv -Path .\AverageUsage.csv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment