What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

Power Shell script for open port check doesn't work properly

Votes:

0

Hi,

I have a problem with PS script that is checking if port on remote host is open or not. I'm executing this script with Custom EXE/Script sensor and it is working but always giving the 1:ERROR value, below you will find the code :

try

{
 
  $tcp=new-object System.Net.Sockets.TcpClient 

  $tcp.connect("10.10.10.10",445)
 
 Write-Host "0:OK"
 
 $tcp.close() 

} 

catch 

{ 

  Write-Host "1:ERROR"

}

Script is working fine with "Invoke command" from Powershell console and its giving the correct value.

Someone ?

powershell remote share windows

Created on Mar 1, 2016 11:01:46 AM

Last change on Mar 1, 2016 3:09:06 PM by  Torsten Lindner [Paessler Support]



1 Reply

Votes:

0

Why not use the integrated port sensor?

Created on Mar 1, 2016 8:26:09 PM by  Stephan Linke [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.