# The perf APIs require a start and end time
# In this case, we specify current time as end time and two hours ago as start time.
$endTime = [DateTime]::UtcNow
$timeDiff = [TimeSpan]::FromHours(1)
$startTime = $endTime - $timeDiff
foreach ($pureArray in $pureArrays)
{
# Create a data object for the each database specifying the database object and the properties to include.
$dataObject = $ScriptContext.CreateFromObject($pureArray, "Id=Id,DisplayName=DisplayName", "ArrayName=ArrayName")
# Call function to add the performance data to the data object.
$readPerfCriteria = New-Object Microsoft.EnterpriseManagement.Monitoring.MonitoringPerformanceDataCriteria("CounterName='Read Latency'")
SetPerfCounterLastValue $dataObject $pureArray $readPerfCriteria 'Read Latency' $startTime $endTime
$writePerfCriteria = New-Object Microsoft.EnterpriseManagement.Monitoring.MonitoringPerformanceDataCriteria("CounterName='Write Latency'")
SetPerfCounterLastValue $dataObject $pureArray $writePerfCriteria 'Write Latency' $startTime $endTime
$ScriptContext.ReturnCollection.Add($dataObject)
}