Jump to content

Add desired services to Pulseway Monitored Services


Recommended Posts

Posted (edited)

Not really sure if anything like this has been posted before.  I've seen a couple posts about removing services or stopping the monitoring of Automatic services.  What I couldn't seem to find in Pulseway was an easy way to take say an inventory of services on machine, and easily convert specific ones to being monitored.  Ideally having the agent inventory all services on the machines and then giving us a way to select which ones we want to monitor through the web portal would be ideal.  Currently we have to log into the actual computer and do it from within the Pulseway Manager desktop app.  Not ideal when you need to monitor specific services across a larger group.  

 

With that said, I wrote this script which has proved useful to me. Maybe someone else will also find it useful. Apologies if something like this has been previously posted.  This will grab the currently monitored services and add them into the list you specify in the script so that you don't lose any currently configured ones when running this. 

NOTE: This is written mainly for Powershell 3.0 and above.  Things like if ($Service -in $NewServiceList) won't work in PS 2.0.  Need to use -contains and swap them around instead. 

$RegPath = "HKLM:\SOFTWARE\MMSOFT Design\PC Monitor\Services"
$CheckServices = Get-ItemProperty -Path $RegPath -ErrorAction SilentlyContinue
 
if ($CheckServices.Count -gt 0) {
    $ExistingServiceList = @()
    for ($Count = 0$Count -lt $CheckServices.Count$Count++) {
        $ExistingServiceList += $CheckServices."Service$Count"
    }
}
else {
    Write-Output "No existing services. Continuing..."
}
 
$NewServiceList = @(
##ADD YOUR SERVICES HERE##
)
 
foreach ($Service in $ExistingServiceList) {
    if ($Service -in $NewServiceList) {
        Write-Output "$Service already in New Service List...continuing..."
    }
    else {
        Write-Output "Adding $Service to New List..."
        $NewServiceList += $Service
    }
}
 
$NewListCount = $NewServiceList.Length
 
Remove-Item -Path $RegPath -Recurse
New-Item -Path $RegPath
$NewCount = 0
foreach ($NewService in $NewServiceList) {
    New-ItemProperty -Path $RegPath -Name ("Service" + $NewCount++) -Value "$NewService" | Out-Null
}
Set-ItemProperty -Path $RegPath -Name "Count" -Value "$NewListCount" | Out-Null
$RecheckRegList = Get-ItemProperty -Path $RegPath
$RecheckRegList
Edited by Mark G38

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...