ActiveXperts Network Monitor

Quicklinks


NOTE: ActiveXperts Network Monitor ships with a large collection of PowerShell scripts to monitor any aspect of your network. Most PowerShell scripts also have a VBScript implementation. Download Now »


Service check

You can use any of the Powershell programs below in ActiveXperts Network Monitor. Click here for an explanation about how to include scripts in ActiveXperts Network Monitor.


Example

#################################################################################
# ActiveXperts Network Monitor PowerShell script, © ActiveXperts Software B.V.
# For more information about ActiveXperts Network Monitor, visit the ActiveXperts 
# Network Monitor web site at http://www.activexperts.com
#################################################################################
# Script
#     Service.ps1
# Description:
#     Starts or stops a sercvice
# Parameters:
#     1) strService (string)  - Service name
#     2) strStatus  - Satus of the service
# Usage:
#      .\Service.ps1 "" "" 
# Sample:
#      .\Service.ps1 "Alerter" "start"
#################################################################################

# Parameters
param
  (
    [string]$strService,
    [string]$strStatus
  )

cls

# Check parameters input
if( ([string]$strService -eq "") -or ([string]$strStatus -eq "") )
  {
    echo "UNCERTAIN: Invalid number of parameters - Usage: .\Service.ps1  "
    exit
  }

  
#################################################################################
# THE SCRIPT ITSELF
#################################################################################
 
$servicePrior = Get-Service $strService

$succ = "SUCCESS: The service " + $strService+ " is Running  DATA: 1"
$err = "ERROR: The service " + $strService+ " is Stopped  DATA: 0"

if( $strStatus -eq "stop" )
  {
    if ($servicePrior.status -eq "Running")
      {
        Stop-Service $strService
      }
    echo $err
    exit
  }
elseif( $strStatus -eq "start" )
  {
    if ( $servicePrior.status -eq "Stopped" )
      {
        Start-Service $strService
      }
    echo $succ
    exit
  }