monitoring bandwidth via Powershell script using WMI Class

Hello,

I am trying to make a script in powershell that can detect that how much bandwidth each RRAS(Routing and remote Access VPN Server) connected user is consuming, then adding up individual bandwidth and compare it to the total available bandwidth on the server in MB/s so far I have written this script to fetch the bandwidth but I have some confusions,

$query = "Select BytesTotalPersec from Win32_PerfFormattedData_Tcpip_NetworkInterface where name='Microsoft Hyper-V Network Adapter'"
Get-WmiObject -Query $query;

Output :

__GENUS          : 2
__CLASS          : Win32_PerfFormattedData_Tcpip_NetworkInterface
__SUPERCLASS     :
__DYNASTY        :
__RELPATH        :
__PROPERTY_COUNT : 1
__DERIVATION     : {}
__SERVER         :
__NAMESPACE      :
__PATH           :
BytesTotalPersec : 122118
PSComputerName   :

Now I have three questions :

1) In the script I want to convert the BytesTotalPerSec to  MB/s what would be the procedure ?

2) Is the BytesTotalPerSec really the bandwidth utilized by the adaptor?

3) If I want to store BytesTotalPerSec value in the variable what would be the procedure.?

Thanks

Frank

Parents
No Data
Reply Children
No Data