从 windows 中的 `netstat` 命令获取特定值 [英] Get specific value from `netstat` command in windows

查看:84
本文介绍了从 windows 中的 `netstat` 命令获取特定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行命令 netstat -ano 我有:

when i run command netstat -ano I have:

PS Y:\PowerShell> netstat -ano

Active Connections

  Proto  Local Address          Foreign Address        State           PID
  TCP    0.0.0.0:80             0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:135            0.0.0.0:0              LISTENING       376
  TCP    0.0.0.0:445            0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:2222           0.0.0.0:0              LISTENING       2364
  TCP    0.0.0.0:3389           0.0.0.0:0              LISTENING       1748
  TCP    0.0.0.0:5985           0.0.0.0:0              LISTENING       4
  TCP    0.0.0.0:6081           0.0.0.0:0              LISTENING       2556
  TCP    0.0.0.0:8001           0.0.0.0:0              LISTENING       3772
  TCP    0.0.0.0:47001          0.0.0.0:0              LISTENING       4

但我真正想要的是:

活动连接

   PID
   4
   376
   4
   2364
   1748
   4
   2556
   3772
   4

我不能使用:netstat -ano|选择 PID 因为它不是 powershell 命令.

I can't use: netstat -ano| select PID because it's not powershell command.

推荐答案

netstat 的 PowerShell 版本是 Get-NetTCPConnection,它将返回对象.

PowerShell version of netstat is Get-NetTCPConnection and it will return with objects.

 Get-NetTCPConnection -State Listen

这篇关于从 windows 中的 `netstat` 命令获取特定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆