If I am reading your error right it looks like you placed the script like this...
Get-Stat -Entity $esx -Instance $ds_uuid -Stat $metric -Realtime -MaxSample ($stats | Measure-Object -Average -Property Value).Average/1000
when it should be...
Get-Stat -Entity $esx -Instance $ds_uuid -Stat $metric -Realtime -MaxSample 1
($stats | Measure-Object -Average -Property Value).Average/1000
On two seperate lines... and don't forget LucD had the -MaxSample as 1