在运维工作中,常常查看某个业务的网络连接状况,在这里借用netstat来实现查找连接。用hash特性避免反复。

$add=@{}
while(1){
ps|?{$_.path  -match 'E:\\games\\梦幻XX}|%{
$id=$_.id
netstat -ano |
    ForEach-Object {
       $i = $_ | Select-Object -Property Protocol , Source , Destination , Mode ,pid
       $null, $i.Protocol, $i.Source, $i.Destination, $i.Mode, $i.pid=  ($_ -split '\s{2,}')
       $i
    }|?

{$_.pid -eq $id}|%{ try{ $add+=@{$_.Destination=$_.Source} $_} catch{} }} sleep 1 } $add


相关文章:

  • 2021-08-03
  • 2022-01-01
  • 2022-01-18
  • 2021-05-16
  • 2021-08-24
  • 2021-12-26
  • 2022-12-23
  • 2021-06-17
猜你喜欢
  • 2022-01-03
  • 2022-02-06
  • 2022-12-23
  • 2021-06-02
  • 2021-12-22
  • 2022-12-23
  • 2021-11-28
相关资源
相似解决方案