If you want to use my Get-Stat2 function, you can do something like this
$stat="datastore.totalWriteLatency.average"
$start= (Get-Date).AddDays(-5)
Get-Datastore|where {$_.Type-eq"NFS"} |%{
$dsName=$_.Name
$uuid=$_.ExtensionData.Info.Url.Split('/')[-2]
$_.ExtensionData.Host|%{Get-View$_.Key|
Get-Stat2-Stat$stat-Instance$uuid-Start$start-IntervalHI2|
SelectTimestamp,CounterName,Interval,Instance,Value,Entity,@{N="Datastore";E={$dsName}}
}
}
With the regular Get-Stat you can do
$stat="datastore.totalWriteLatency.average"
$start= (Get-Date).AddDays(-5)
Get-Datastore|where {$_.Type-eq"NFS"} |%{
$dsName=$_.Name
$uuid=$_.ExtensionData.Info.Url.Split('/')[-2]
Get-VMHost-Datastore$_|
where {$_.Instance-eq$uuid} |
SelectTimestamp,MetricId,IntervalSecs,Instance,Value,@{N="Entity";E={$_.Entity.Name}},@{N="Datastore";E={$dsName}}
}