PS script to calculate the percentage of B/W being used by each transferring client.

$allCli = gwmi -namespace root\StifleR -Query "Select * from Clients where ActivelyTransferring = True"

foreach ( $Client in $allCli ) {

$PerCentUsed = “{0:P2}” -f ($Client.bandwidthUsed / $Client.bandwidthallowed)

$UsedBW = “{0:N2}” -f ($Client.bandwidthUsed)

#display some basic stats

 $Client.ComputerName  + "  Allowed: " +  $Client.bandwidthallowed + "  Used: " + $UsedBW  + "  Percent: " + $PerCentUsed

 #output more stats to .csv

  [PSCustomObject]@{

       IsRedLeader = $Client.IsRedLeader

       BITSQSize = $Client.JobsOnClient

       NetworkID =  $Client.NetworkId

       SystemName = $Client.ComputerName

       AllowedBW = $Client.bandwidthallowed

       UsedBW =  $UsedBW

       PercentUsed = $PerCentUsed

       } | Export-Csv C:\ActiveClientBWPercent.csv -notype -Append

 

 }