Manchmal braucht man einfach mal eine schnelle Prüfung eines Ports um zum Beispiel die Funktionsweise von Applikationen oder Hardware zu testen. Entsprechend habe ich mir ein kleines Skript (Chkprt.ps1) erstellt, um diese Funktionalität einfach abzubilden.
$ipaddress=$args[0] $portaddress=$args[1] $Port = New-Object System.Net.Sockets.TCPClient($ipaddress,$portaddress); catch {} if ($port -eq $Null) { echo " Port $portadress an $ipaddress ist erreichbar "; } else { echo " Port $portadress an $ipaddress ist NICHT erreichbar "; $port = $Null }
Der Aufruf sieht für einen Drucker dann als Beispiel dann wie folgt aus:
.\chkprt.ps1 192.168.2.3 9100