Jump to content

ethorup

Members
  • Posts

    8
  • Joined

  • Last visited

Posts posted by ethorup

  1. Small Correction: The scheduled task can be run on demand, but by default it restarts the pulseway service once a day at 11am, which in theory, should force it to check for updates. 

    So one of the problems I ran into with pulseway is, sometimes I would want to restart the service.  Doesn't really matter why, could be to get it to check for new updates to the pulseway agent and get them on the latest version.  The problem was that if I just setup a script to restart the service, say like this ReStart-Service "Pulseway" what would happen is that it would send the command in whatever user environment pulseway runs in, it would execute it, the service would stop, and thennnn.......... nothing! Because we stopped the service, it kills whatever user environment pulseway was using including the script and it never finishes the command.  It's really weird.  So I setup this wonderful little script that creates a scheduled task, that can be run on demand using another script.  It keeps you from running a restart service task on all your end points and suddenly losing connection with them all.... not fun.

    So here is the first script you put in to pulseway.  Read the comments and change the working directory, user account and password to match what you use.  It also requires a universal user account on all your workstations that you want to use it on.

    # this script will create a scheduled task that runs a powershell script that restarts the pulseway service.

    # This line deletes the task if it already exists.  That way if you make changes to the task it will create a fresh copy of it.
    schtasks /delete /F /tn "Restart Pulseway"

    # working directory path
    $workd = "c:\temp"

    # Check to see if working directory exists and create if it does not.
    If (!(Test-Path -Path $workd -PathType Container))

    New-Item -Path $workd  -ItemType directory 
    }

    # Create a variable with the entire contents of the XML file used to create the scheduled task
    $text = '<?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
      <RegistrationInfo>
        <Date>2017-04-24T12:50:26.5825569</Date>
        <Author>ECHO-FAMILYPC\Echo</Author>
        <Description>this will restart the pulseway service, forcing it to check for and implement any updates.</Description>
        <URI>\Restart Pulseway</URI>
      </RegistrationInfo>
      <Triggers>
        <CalendarTrigger>
          <StartBoundary>2017-04-24T11:00:00</StartBoundary>
          <Enabled>true</Enabled>
          <ScheduleByDay>
            <DaysInterval>1</DaysInterval>
          </ScheduleByDay>
        </CalendarTrigger>
      </Triggers>
      <Principals>
        <Principal id="Author">
          <UserId>S-1-5-21-3275926025-1642913270-681481828-1006</UserId>
          <LogonType>Password</LogonType>
          <RunLevel>HighestAvailable</RunLevel>
        </Principal>
      </Principals>
      <Settings>
        <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
        <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
        <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
        <AllowHardTerminate>true</AllowHardTerminate>
        <StartWhenAvailable>true</StartWhenAvailable>
        <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
        <IdleSettings>
          <StopOnIdleEnd>true</StopOnIdleEnd>
          <RestartOnIdle>false</RestartOnIdle>
        </IdleSettings>
        <AllowStartOnDemand>true</AllowStartOnDemand>
        <Enabled>true</Enabled>
        <Hidden>false</Hidden>
        <RunOnlyIfIdle>false</RunOnlyIfIdle>
        <WakeToRun>true</WakeToRun>
        <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
        <Priority>7</Priority>
      </Settings>
      <Actions Context="Author">
        <Exec>
          <Command>Powershell.exe</Command>
          <Arguments>-ExecutionPolicy Bypass '+$workd+'\rstrtPulse.ps1</Arguments>
        </Exec>
      </Actions>
    </Task>
    '

    # Create a variable containing the entire contents of the powershell script that will restart the pulseway service.
    $text2 = 'ReStart-Service "Pulseway"'

    # Pump the contents of the two variables into the actuall files to be used
    $text | Set-Content $workd\rstrtPulse.xml
    $text2 | Set-Content $workd\rstrtPulse.ps1

    # Command that actually creates the scheduled task.  You will need to change UserName and Password to the universal admin creds that you may use.
    schtasks.exe /create /xml "$workd\rstrtPulse.xml" /tn "Restart Pulseway" /ru UserName /rp Password

    #Wait a couple seconds
    Start-Sleep -s 2

    # Delete the files when done.  Dont need anyone knowing my secrets!
    del $workd\rstrtPulse.xml
    del $workd\rstrtPulse.ps1

     

    Here is the second script that you will use to execute the scheduled task

    schtasks /run /tn 'Restart Pulseway'

     

    Have fun, stay safe, always test your scripts!

  2. So, I was running into the same issue a while ago and decided to try and crack the puzzle.  It requires a couple of different things.

    The first script you need is to generate a universal user name and password across all your client systems.  The reason for this is that in order to create a 'Scheduled Task' on the system, it requires an accompanying user account to be able to run the task. 

    Once this was done, I really had to dig for this one, I created a PS script that creates a couple of files.  The first one is an XML file containing the settings for the scheduled task.  The other is a powershell script that the scheduled task executes to ensure the pulseway services is running.  I have mine set to check and make sure the service is running every hour.  

    Here is the full script that you would put into pulseway.

     

    # this script will create a scheduled task that runs a powershell script that checks to make sure the Pulseway service is running.

    # This line deletes the task if it already exists.  That way if you make changes to the task it will create a fresh copy of it.
    schtasks /delete /F /tn "Check Pulseway"

    # working directory path
    $workd = "c:\temp"

    # Check to see if working directory exists and create if it does not.
    If (!(Test-Path -Path $workd -PathType Container))

    New-Item -Path $workd  -ItemType directory 
    }

    # Create a variable with the entire contents of the XML file used to create the scheduled task
    $text = '<?xml version="1.0" encoding="UTF-16"?>
    <Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
      <RegistrationInfo>
        <Date>2017-04-10T10:47:49.7419447</Date>
        <Author>Author</Author>
        <URI>\Check Pulseway</URI>
      </RegistrationInfo>
      <Triggers>
        <CalendarTrigger>
          <Repetition>
            <Interval>PT1H</Interval>
            <StopAtDurationEnd>false</StopAtDurationEnd>
          </Repetition>
          <StartBoundary>2017-04-10T10:43:02</StartBoundary>
          <Enabled>true</Enabled>
          <ScheduleByDay>
            <DaysInterval>1</DaysInterval>
          </ScheduleByDay>
        </CalendarTrigger>
      </Triggers>
      <Principals>
        <Principal id="Author">
          <UserId>S-1-5-21-3327590030-3417645755-2999866733-1004</UserId>
          <LogonType>Password</LogonType>
          <RunLevel>HighestAvailable</RunLevel>
        </Principal>
      </Principals>
      <Settings>
        <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
        <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
        <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
        <AllowHardTerminate>true</AllowHardTerminate>
        <StartWhenAvailable>false</StartWhenAvailable>
        <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
        <IdleSettings>
          <StopOnIdleEnd>true</StopOnIdleEnd>
          <RestartOnIdle>false</RestartOnIdle>
        </IdleSettings>
        <AllowStartOnDemand>true</AllowStartOnDemand>
        <Enabled>true</Enabled>
        <Hidden>false</Hidden>
        <RunOnlyIfIdle>false</RunOnlyIfIdle>
        <WakeToRun>false</WakeToRun>
        <ExecutionTimeLimit>PT72H</ExecutionTimeLimit>
        <Priority>7</Priority>
      </Settings>
      <Actions Context="Author">
        <Exec>
          <Command>Powershell.exe</Command>
          <Arguments>-ExecutionPolicy Bypass '+$workd+'\ChkPulse.ps1</Arguments>
        </Exec>
      </Actions>
    </Task>'

    # Create a variable containing the entire contents of the powershell script that checks to see if pulseway is running or not.
    $text2 = 'function FuncCheckService{
    param($ServiceName)
    $arrService = Get-Service -Name $ServiceName
    $Start = "Started "

    if ($arrService.Status -ne "Running"){
    Start-Service $ServiceName
    }
    }
     
    FuncCheckService -ServiceName "Pulseway"
    '

    # Pump the contents of the two variables into the actuall files to be used
    $text | Set-Content $workd\ChkPulse.xml
    $text2 | Set-Content $workd\ChkPulse.ps1

    # Command that actually creates the scheduled task.  You will need to change UserName and Password to the universal admin creds that you may use.
    schtasks.exe /create /xml "$workd\ChkPulse.xml" /tn "Check Pulseway" /ru UserName /rp Password

    #Wait a couple seconds
    Start-Sleep -s 2

    # Delete the files when done.  Dont need anyone knowing my secrets!
    del $workd\chkpulse.ps1
    del $workd\chkpulse.xml

  3. This script will download the small online installer, generate the silent install cfg file and run the installer.  The timer near the end is set for 3 minutes as it has to download the full installer first and Java takes a while to install anyway.  If you want to get the latest version just go to https://java.com/en/download/win10.jsp and copy the link from the button that says "Agree and start free download".  Then past this link into the $source variable.  I find that this installer works on both windows 7 and windows 10.

     

    # Download and silent install Java Runtime Environement

    # working directory path
    $workd = "c:\temp"

    # Check if work directory exists if not create it
    If (!(Test-Path -Path $workd -PathType Container))

    New-Item -Path $workd  -ItemType directory 
    }

    #create config file for silent install
    $text = '
    INSTALL_SILENT=Enable
    AUTO_UPDATE=Enable
    SPONSORS=Disable
    REMOVEOUTOFDATEJRES=1
    '
    $text | Set-Content "$workd\jreinstall.cfg"
        
    #download executable, this is the small online installer
    $source = "http://javadl.oracle.com/webapps/download/AutoDL?BundleId=230511_2f38c3b165be4555a1fa6e98c45e0808"
    $destination = "$workd\jreInstall.exe"
    $client = New-Object System.Net.WebClient
    $client.DownloadFile($source, $destination)

    #install silently
    Start-Process -FilePath "$workd\jreInstall.exe" -ArgumentList INSTALLCFG="$workd\jreinstall.cfg"

    # Wait 120 Seconds for the installation to finish
    Start-Sleep -s 180

    # Remove the installer
    rm -Force $workd\jre*

  4. I'm not sure what it is, but it seems lately that Kaspersky AV (aka pulseway antivirus) is picking up a lot of adware instances.  I like this and use it to keep my clients safe.  But sometimes it can be a little overwhelming to have to click through each one individually to delete them.  Is there any way we can get an option to select multiple items and perform an operation on those multiple items?  It would be nice to have better overall av integration, but this is one that I would love to see first.

    Sometimes when we bring on a new client with a lot of computers, and once we install the antivirus software, we get slammed with notification for adware, maleware, trojans, etc.  It just sucks having to click each one to choose what to do with it.  When there are hundreds of notifications, it can take a while.

  5. We get notifications of systems going off line and they generate a ticket in the Pulseway PSA ticketing system.  But if that system comes back on-line and shows a normal status, it does not automatically complete or close the ticket out.  Right now we have to manually go in to each ticket and close these tickets.  Is there a way that the system can automatically close these tickets when their status changes to normal?

×
×
  • Create New...