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

September 6th, 2015 9:04am

Hello

I have created a variable to store the value of BytesPerSec but it keeps on changing with time I wan to take difference between two values of BytesPerSec but values in the variable keeps on changing.

September 6th, 2015 1:30pm

This forum is not a help desk for end users. It is a forum for technicians.  You need to start by taking the time to learn PowerShell. We will not incrementally write your script for you.

Start here: https://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx?f=255&MSPPError=-2147217396

Free Windows Admin Tool Kit Click here and download it now
September 6th, 2015 1:49pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics