- $counterPath = '\Network Interface(*)\Bytes Total/sec' #计数器:总流量
- $sampleInterval = 60 # 样本间隔时间,单位:秒
- $maxSpeed = 500000000 # 最大网络流量,单位:bps
- $msgServer = '192.168.180.50'
-
- Get-Counter -Counter $counterPath -SampleInterval $sampleInterval -Continuous | ForEach-Object {
- $mi = $_.CounterSamples | Measure-Object -Property CookedValue -Sum
- $bps = $mi.Sum * 8
- $bps
- if ($bps -lt $maxSpeed) {
- msg * /server:$msgServer "请注意,网卡流量低于预定值,请及时处理"
- }
- }
复制代码 powershell脚本. 编码: ANSI |