Last active
March 15, 2019 10:39
-
-
Save biacz/e04be1b46c679ebe805a5bf9928f6f31 to your computer and use it in GitHub Desktop.
This file contains 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
Connect-VIServer asdf | |
Clear-Variable report | |
$report = Get-Datacenter -PipelineVariable datacenter | | |
ForEach-Object { | |
get-cluster -Location $_ -PipelineVariable cluster | | |
ForEach-Object { get-vmhost -Location $_ | | |
foreach-object {[pscustomobject]@{ | |
Datacenter=$datacenter.Name; | |
Cluster=$cluster.Name; | |
Name=$_.Name; | |
NumCPU=$_.NumCpu; | |
MemoryGB=[math]::Round($_.MemoryTotalGB); | |
MemoryUsedGB=[math]::Round($_.MemoryUsageGB); | |
CpuTotalMhz=[math]::Round($_.CpuTotalMhz); | |
CpuUsedMhz=[math]::Round($_.CpuUsageMhz); | |
MemoryUsedPct=[math]::Round(($_.MemoryUsageGB/$_.MemoryTotalGB*100)); | |
CpuUsedPct=[math]::Round($_.CpuUsageMhz/$_.CpuTotalMhz*100); | |
NumVMs=$(get-vm -Location $_).count | |
} | |
} | |
} | |
} | |
$report | export-csv -Force -NoTypeInformation -path "c:\temp\powerbifeed.csv" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment