Skip to main content
All CollectionsGeneral
Pulseway Watcher deployment manual
Pulseway Watcher deployment manual
Paul Csiki avatar
Written by Paul Csiki
Updated over a year ago

The Pulseway Watcher is a small script written in PowerShell that adds an entry to Windows Task Scheduler. In an unlikely event of Pulseway service becoming unavailable, the newly created Task Scheduler entry will automatically restart the service.

In order to deploy it on a single machine please follow the following steps:

  1. Create a script

Navigate to WebApp - > Automation -> Scripts -> Build-In and select the New Script

Copy the script from the bottom section of this document, paste it and save as PowerShell

   2. Execute it

Navigate to WebApp -> Systems -> Systems -> your_system_name -> Scripts

Select the Pulseway Watcher script

and execute it!

In order to deploy it on multiple machines please follow the following steps:

  1. Create a script

Navigate to WebApp - > Automation -> Scripts -> Build-In and select the New Script

Copy the script from the bottom section of this document, paste it and save as PowerShell:

   2. Create a task and run it

Navigate to WebApp - > Automation -> Tasks and select the Create Task  

Fill out the Overview tab and select your scope from the drop down menu

In the Script tab select the Pulseway Watcher script and add it to the task by selecting the “+” sign. You can now save it.

Once completed go back to the Task section and run it in the usual manner.

Script:

#Create the scheduled task Pulseway Watcher

Path for the Pulseway watcher

$file = $false
$workdir = $Env:WinDir

# Check if work directory exists if not create it
try{
    #check if the file exists. If yes, then delete it'
    $file = Test-Path -Path "$workdir\pulseway_watcher.cmd"
    If ($file)
    { Remove-Item -Path "$workdir\pulseway_watcher.cmd" -force
    Write-Host "The file was updated"
    }

    # Download the Pulseway watcher

    $source = "https://www.pulseway.com/download/startcheck.txt"
    $destination = "$workdir\pulseway_watcher.cmd"

    # Check if Invoke-Webrequest exists otherwise execute WebClient


        $WebClient = New-Object System.Net.WebClient
        $webclient.DownloadFile($source, $destination)

    Start-Sleep -s 10

    # Check if the scheduled task 'Pulseway watcher' exists, if not, then create it.
    $taskExists = schtasks /query /TN "Pulseway Watcher" 2>NULL
   #$taskExists = Get-ScheduledTask -ErrorAction SilentlyContinue | Where-Object {$_.TaskName -like "Pulseway Watcher" } | select state

    if($taskExists) {
       Write-Host "The scheduled task 'Pulseway Watcher' already exists"
       exit 0
    } else {
       SCHTASKS /Create /SC MINUTE /MO 5 /TN "Pulseway Watcher" /TR $destination /RU SYSTEM
       Write-Host "The scheduled task 'Pulseway Watcher' was created successfully"
       exit 0
    }
​   
}catch{
  Write-Host "An unexpected error occurred"
  Break
  exit 1
}

Did this answer your question?