Hello,
I'm trying to run this PowerShell function via the command line. I know that it need a host to run against.
function Get-VMHostLunLatency {
param([parameter(Mandatory=$true, ValueFromPipeline=$true)] $VMHost)
process {
$luns = Get-ScsiLun -VmHost $VMHost
$DiskStats = $VMHost |
Get-Stat -stat disk.totalreadlatency.average,disk.totalwritelatency.average -maxsamples 1 -realtime
foreach ($lun in $luns) {
$Stats = $DiskStats |
Where { $_.Instance -eq $Lun.CanonicalName }
if ($stats.length -ne $null) {
$obj = New-Object PSObject
$obj | Add-Member -MemberType NoteProperty -Name VMHost -Value $VMHost.Name
$obj | Add-Member -MemberType NoteProperty -Name Lun -Value $lun.CanonicalName
$obj | Add-Member -MemberType NoteProperty -Name ReadLatency -Value ($stats[0].Value)
$obj | Add-Member -MemberType NoteProperty -Name WriteLatency -Value ($stats[1].Value)
Write-Output $obj
}
}
}
}
So, what I'm trying is this:
c:\scripts> .\EsxLunLatency.ps1 Get-VMHostLunLatency "Host1.test.local"
Which is not returning any data.
The file name is EsxLunLatency.ps1 and the function name is Get-VMHostLunLatency, so what I'm I doing wrong.
Thanks,