最简单的单行PowerShell代码
本帖最后由 itubay 于 2024-8-20 23:59 编辑一行代码测试指定ip地址是否通:
if((ping 192.168.0.1) -match "TTL"){write-host "online"}else{write-host "offliine"}
一行代码测试指定ip的端口是否开放:
try{(new-object Net.Sockets.TcpClient).Connect("192.168.0.1",26);write-host "open"}catch{write-host "close"}
页:
[1]