【发布时间】:2023-01-04 21:58:23
【问题描述】:
我试图使用如下所示的 powershell 检查端口是否打开。
我的问题是:我想检查多个端口,例如 389,53,135。我们该怎么做?
这是我的脚本:
$Ipaddress= "xx.xx.xx.xx"
$Port= "389"
$t = New-Object Net.Sockets.TcpClient
$t.Connect($Ipaddress,$Port)
if($t.Connected)
{
"Port $Port is operational"
}
else
{
"Port $Port is closed, You may need to contact your IT team to open it. "
}
我想要的输出:
Port 389 is operational;Port 53 is operational;Port 135 is operational
【问题讨论】:
标签: powershell