title: \network adapter(*)\bytes total/sec vs. task manager/performance -powershell
body: <p>On Windows 10, in task manager/performance it gives the values for 'Receive' and 'Send' for network adapters. I got curious as to how MS does this so I thought of performance counters in powershell. So I cobbled together a quick bit of code to experiment with, put it in a background job, this:</p>
  
  <pre><code>$Computer = hostname;
  $sndrecsum = {((get-counter -Counter '\network adapter(*)\Bytes Received/sec' -MaxSamples 30).CounterSamples | measure cookedvalue –Sum).Sum};
  $sptstb = New-Object System.Net.WebClient;
  $sptstb.DownloadFile('http://client.akamai.com/install/test-objects/10MB.bin', 'Out-Null');
  Start-Job -Name sxrxs -scriptblock $sndrecsum -ArgumentList $Computer;
  Get-Job -Name sxrxs | Wait-Job; $sndrecsumout = Get-Job -Name sxrxs | Receive-Job; ($sndrecsumout | measure -Maximum).Maximum
  </code></pre>
  
  <p>here's the issue. The output '($sndrecsumout | measure -Maximum).Maximum' should be getting the maximum value in the array $sndrecsumout. It does do that but the max value in the array is always wayyyy lower than it should be and never matches that shown in task manager/performance for 'Receive' and 'Send' (after conversion to the prevailing units shown in task manager/performance at the same time). So i'm not sure if task manager/performance is using performance counters or if i'm screwing up somewhere.</p>
  
  <p>Anyway, two questions: First, how does task manager/performance get the values for 'Receive' and 'Send'? - and - Two, am I screwing up with the way i'm trying to do this?</p>
  
  <p>Thanks for replies and advice in advance. </p>