Contact Info

ActiveXperts Network Monitor ships with a powerful set of pre-defined checks. Each individual check has a static number of configuration items. To monitor other items, or to combine monitoring items, you can make use of custom PowerShell checks.

Most of the built-in checks have a PowerShell equivalent, implemented as a PowerShell (.ps1) script file. Out-of-the-box, each PowerShell script monitors the same items as the built-in check. Feel free to modify the script.

To add a new PowerShell-based Ftp monitoring check, do the following:

To customize the above monitoring check, click on the 'Edit button' next to the 'Script File' selection box. Notepad will be launched. You can now make changes to the PowerShell script.

Powershell Ftp check

Ftp.ps1 script source code

#################################################################################
# ActiveXperts Network Monitor PowerShell script, (c) ActiveXperts Software B.V.
# For more information about ActiveXperts Network Monitor, visit the ActiveXperts 
# Network Monitor web site at https://www.activexperts.com
#################################################################################
# Script
#     FTP.ps1
# Description:
#     Login to an FTP server, change the directory and check for file existence.
#     This function uses the ActiveXperts Network Component, an ActiveXperts product.
#     ActiveXperts Network Component is automatically licensed when ActiveXperts 
#     Network Monitor is purchased
#     For more information about ActiveXperts Network Component, see: 
#       www.activexperts.com/network-component
# Parameters:
#     1) strHost - Host name or IP address of the FTP host
#     2) strAccount - FTP account; use #anonymous# for anonymous FTP access
#     3) strPassword - FTP password; use an e-mail address for anonymous FTP access
#     4) strDir - The directory where the file should be located
#     4) strFile - The file to check 
# Usage:
#     .\FTP.ps1 '<Host>' '<Account>' '<Password>' '<Directory>' '<File>'
# Sample:
#     .\FTP.ps1 'ftp.activexperts-labs.com' 'anonymous' 'me@myself.me' 'Samples/NetworkMonitor" "NetworkMonitor.txt"
#################################################################################

# Parameters
param 
  (
    [string]$strHost,
    [string]$strAccount,
    [string]$strPassword,
    [string]$strDir,
    [string]$strFile
  )

cls

# Check paramters input
if( ([string]$strHost -eq "") -or 
    ([string]$strAccount -eq "") -or 
    ([string]$strPassword -eq "") -or 
    ([string]$strDir -eq "") -or
    ([string]$strFile -eq "")
  )
{
  $res = "UNCERTAIN: Invalid number of parameters - Usage: .\ftp.ps1 <strDnsServer> <strHost> <strExpectedValue>"
  echo $res
  exit
}

$found = $false

# Create object
$objFtpServer = new-object -comobject ActiveXperts.FtpServer

$objFtpServer.Connect( $strHost, $strAccount, $strPassword )
if ( $objFtpServer.LastError -ne 0 )
{
  return "UNCERTAIN: Login failed, error #" + $objFtpServer.LastError + ": " + $objFtpServer.GetErrorDescription( $objFtpServer.LastError )
  exit
}


#################################################################################
# THE SCRIPT ITSELF
#################################################################################
    
# Use binary transfer for GetFile calls
$objFtpServer.BinaryTransfer = $true

# Change directory
$objFtpServer.ChangeDir($strDir)

if ( $objFtpServer.LastError -ne 0 )
{
  return  "UNCERTAIN: Failed to change directory, error #" + $objFtpServer.LastError + ": " + $objFtpServer.GetErrorDescription( $objFtpServer.LastError )
  exit
}

# Iterate over all files
$objFtpFile = $objFtpServer.FindFirstFile()

while ( $objFtpServer.LastError -eq 0 )
{
  if( $objFtpFile.Name -eq $strFile )
  {
    $found = $true
    $objFtpServer.Disconnect()
  }
   $objFtpFile = $objFtpServer.FindNextFile()
}

if ( $found -eq $true )
{
  return "SUCCESS: File [" + $strFile + "] found on FTP server [" + $strHost + "]"
}
else
{
  return "ERROR: File [" + $strFile + "] not found on FTP server [" + $strHost + "]"
} 

$objFtpServer.Disconnect()