Jump to content

Mark G38

Members
  • Posts

    131
  • Joined

  • Last visited

Posts posted by Mark G38

  1. 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
  2. Going to bring this thread back to the top.  If anyone else feels that having the ability to input at run time a variable they declared as a custom field in their scripts, please upvote.  This is probably one of the single biggest improvements I want to see with Pulseway.  Custom variables should be able to be set to prompt at run for input.  We should also be able to set Customer level variables that are static and can be called in a given script.  

    Here is the link to the feature request.  I did search and didn't find someone else asking about this, but I may have missed it. Either way, doesn't seem high on the list of votes so getting more attention to it would be great. 

    https://pulseway.featureupvote.com/suggestions/189283/more-robust-input-and-site-variables

×
×
  • Create New...