Powershell实现Telnet Port

2021-07-20 20:04

阅读:461

标签:hid   gif   src   sock   pre   opened   catch   each   ide   

Telnet Port 脚本

技术分享技术分享
 1 $servers = get-content D:\ps\ServerIPAddress.TXT
 2 $portToCheck = ‘80 3 for($i=1;$i -le 120;$i++)
 4 {
 5 foreach ($server in $servers) {
 6  
 7     If ( Test-Connection $server -Count 1 -Quiet) {
 8     
 9         try {       
10             $null = New-Object System.Net.Sockets.TCPClient -ArgumentList $server,$portToCheck
11             $props = @{
12                 Server = $server
13                 PortOpen = ‘Yes‘
14                 Date=get-date
15             }
16         }
17  
18         catch {
19             $props = @{
20                 Server = $server
21                 PortOpen = ‘No‘
22                 Date=get-date
23             }
24         }
25     }
26  
27     Else {
28         
29         $props = @{
30             Server = $server
31             PortOpen = ‘Server did not respond to ping‘
32             Date=get-date
33         }
34     }
35  
36     New-Object PsObject -Property $props | Out-File -Append D:\PS\test-telnet.csv
37 }
38 Start-Sleep -s 10
39 }
View Code

 

Powershell实现Telnet Port

标签:hid   gif   src   sock   pre   opened   catch   each   ide   

原文地址:http://www.cnblogs.com/scentpath/p/7054601.html


评论


亲,登录后才可以留言!