New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

300.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


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

Votes:

0

Your Vote:

Up

Down

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 by  kapel (0) 1

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



1 Reply

Votes:

0

Your Vote:

Up

Down

Why not use the integrated port sensor?

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



Please log in or register to enter your reply.


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.