-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6b91769
commit c3c068e
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
Set-Location C:\Users\fabia\Documents\Git\Chocolatey-package\Chocolatey-packages\ | ||
|
||
# Nom partiel de l'interface réseau que vous voulez surveiller | ||
$interfaceNameFilter = "netxtreme gigabit ethernet _3" | ||
|
||
# Récupérer les données réseau avant l'exécution du script pour l'interface spécifiée | ||
$networkStatsBefore = Get-WmiObject -Query "SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface" | Where-Object { $_.Name -like "*$interfaceNameFilter*" } | ||
|
||
if (-not $networkStatsBefore) { | ||
Write-Output "Interface réseau non trouvée." | ||
exit | ||
} | ||
|
||
# Exécuter votre script (ou simuler l'exécution avec une pause) | ||
.\au\update_all.ps1 | ||
|
||
# Récupérer les données réseau après l'exécution du script pour l'interface spécifiée | ||
$networkStatsAfter = Get-WmiObject -Query "SELECT * FROM Win32_PerfRawData_Tcpip_NetworkInterface" | Where-Object { $_.Name -like "*$interfaceNameFilter*" } | ||
|
||
# Calculer la quantité de données transférées | ||
$bytesSentBefore = ($networkStatsBefore | Measure-Object -Sum -Property BytesSentPersec).Sum | ||
$bytesSentAfter = ($networkStatsAfter | Measure-Object -Sum -Property BytesSentPersec).Sum | ||
$bytesReceivedBefore = ($networkStatsBefore | Measure-Object -Sum -Property BytesReceivedPersec).Sum | ||
$bytesReceivedAfter = ($networkStatsAfter | Measure-Object -Sum -Property BytesReceivedPersec).Sum | ||
|
||
$totalBytesSent = $bytesSentAfter - $bytesSentBefore | ||
$totalBytesReceived = $bytesReceivedAfter - $bytesReceivedBefore | ||
|
||
$totalBytesTransferred = $totalBytesSent + $totalBytesReceived | ||
|
||
# Afficher la quantité transférée en Mo | ||
$totalMBTransferred = [math]::round($totalBytesTransferred / 1MB, 2) | ||
Write-Output "Total data transferred on interface '$interfaceNameFilter': $totalMBTransferred MB" |