Quantcast
Channel: THWACK: Popular Discussions - Script Lab
Viewing all articles
Browse latest Browse all 9937

Unable to get PS monitor to take arguments

$
0
0

I've a baby PS script (cut down from the existing time drift PS monitor) that I'm trying to get to take arguments from the powershell monitor.  Any help would be appreciated.

 

The below code works fine when I run it in ISA.

 

# Argument example: time.nist.gov 13

function PortCheck ([string]$remotesystemname,[int]$port) {

 

$Socket = $null;

 

$Socket = New-Object Net.Sockets.TcpClient;

       

$Socket.Connect($remotesystemname, $Port);

       

      

if ($Socket.Connected) {

       

             $stat = 0;

          Write-host "Message: Port $port to $remotesystemname is open.";

         Write-host "Statistic: $stat";

         Exit 0;

             }

        

        else {

             $stat = 1;

          Write-host "Message: Port $port to $remotesystemname is closed.";

         Write-host "Statistic: $stat";

         Exit 1;   

             }

 

}


Viewing all articles
Browse latest Browse all 9937

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>