Created
April 4, 2016 22:15
-
-
Save aaronlake/7926c9199fb625f98269304b99910b68 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
# Beginning script | |
# Section 1 – vCenter Server settings | |
$vcentertocollectstatsfrom = “192.168.1.101” | |
$vcenterusername = “root” | |
$vcenterpassword = “P@ssw0rd” | |
# Section 2 – Collection time frame | |
$noofdaystocollect = “7” | |
# Section 3 – CSV Output filename and directory | |
$csvoutput = “C:\scriptoutput\ZertoOutput.csv” | |
# Nothing to edit below this line | |
function LoadSnapin{ | |
param($PSSnapinName) | |
if (!(Get-PSSnapin | where {$_.Name -eq $PSSnapinName})){ | |
Add-pssnapin -name $PSSnapinName | |
} | |
} | |
LoadSnapin -PSSnapinName “VMware.VimAutomation.Core” | |
connect-viserver -server $vcentertocollectstatsfrom -user $vcenterusername -password $vcenterpassword | |
$report = @() | |
Get-VM | %{$stats = Get-Stat -Entity $_ -Stat disk.write.average -Start (Get-Date).adddays(-$noofdaystocollect) -ErrorAction SilentlyContinue | |
if($stats){ | |
$statsGrouped = $stats | Group-Object -Property MetricId | |
$row = “” | Select Name, WriteAvgKBps, WriteAvgMBps | |
$row.Name = $_.Name | |
$row.WriteAvgKBps = ($statsGrouped | where {$_.Name -eq “disk.write.average”} | %{$_.Group | Measure-Object -Property Value -Average}).Average | |
$row.WriteAvgMBps = $row.WriteAvgKBps/1024 | |
$row.WriteAvgKBps = “{0:N2}” -f $row.WriteAvgKbps | |
$row.WriteAvgMBps = “{0:N2}” -f $row.WriteAvgMBps | |
$report += $row | |
} | |
} | |
$report | Export-Csv $csvoutput | |
# End of script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment