Skip to main content
All CollectionsÜbercool tricks and answers
Run scripts on devices - P9 Tasks feature
Run scripts on devices - P9 Tasks feature
IT-Man avatar
Written by IT-Man
Updated over 2 years ago

Table of contents

With Tasks you can instruct devices to install or uninstall applications such as Google Chrome, Adobe Reader, LibreOffice, etc. You can also write a PowerShell, Batch, Bash, Python, Ruby or Perl scripts and have devices run it. In short, with Tasks you've got the ability to remotely command devices to perform jobs from the comfort of your computer using the Panorama9 Dashboard.

To create a new Task navigate to the "Dashboard" -> "Tasks" and click on the "+ Add task". To run the Task, devices must have the Panorama9 Agent installed.

Tasks can be scheduled to run at a specific date and time. Or started instantly. Offline devices will receive the Task if they come online within 24 hours (you can also wake offline devices using the Wake-on-LAN feature).

Devices in different time zones will start the scheduled Task at the configured time. Meaning that if you configured a Task to start at 01:00 am, then when it is 01:00 am locally, the device will execute it.

Install an application

The Panorama9 system comes with a long list of applications you can choose to install. If you've got a device where e.g. Google Chrome isn't installed, you can quickly install it by navigating to the device and then click "Start task", set type to "Install" and select "Google Chrome" from the drop-down list.

If you want the installation to be done at a specific time, then schedule a new Task by navigating to "Tasks", click on "+ Add task", select platform, set type to "Install", choose application and select devices or groups that should receive the application.

Should you want to install software not found on the application drop-down list, you're encouraged to use a script (see below).

Note: The device will download the required installer package using the Internet. Latest stable version of the application will be installed.

Pro-tip macOS: While we've included many of the most relevant applications there are many more you can choose from. The Panorama9 Agent supports brew cask packages. To list all applications open a terminal and do "p9-brew cask search". If you find an application you wish to install then create a Bash script (see below) with the relevant code.

Uninstall an application

Unwanted software can be uninstalled by selecting it and then click on "Uninstall selected". You can uninstall it on a specific device or across your network.

To uninstall on a specific asset just navigate to the device, click the "Software" tab, select the unwanted software from the list and then finally hit the "Uninstall selected" button.

To uninstall specific software across multiple devices select "Assets" -> "Software" and highlight an application to remove and then click "Uninstall selected".

Note: If the uninstall process requires a reboot, this is suppressed. For these types of uninstall you must perform the reboot (you can use the Reboot device feature using the Panorama9 Dashboard).

Run a script

Before you can instruct devices to run a script you must add one to the "Tasks" -> "Scripts repository". You can write code in any of the supported scripting languages. Note that any console output generated at execution time by a device, will be recorded and can later be viewed from the "History" tab. Non zero exit code will result in the execution being marked as "Failed".

Once you've saved a script to the repository, you can create a new Task and select it. The Task can be scheduled and set to run on one or more devices. You can also ask a specific device to instantly run the script. Just navigate to the device and click on the "Start task" in the "Remote tools" box.

The script will be executed in the context of the Panorama9 Agent service/daemon (on Windows "system" and on macOS "root", unless the Panorama9 Agent is configured to run otherwise).

Scripts that can be run on Windows: Batch and Powershell

Scripts that can be run on macOS/OSX: Bash, Perl, Python and Ruby

Result of execution

Once the Panorama9 Agent has completed a Task the result is returned and can be viewed through the Panorama9 Dashboard. Navigate to "Tasks" -> "History" and select a completed Task.

Each device that has run the Task is listed along with the result, duration and any console output.

Task result for each device can be:

  • Successful - completed with exit code zero

  • Failed - completed with a non zero exit code

  • Did not run - device didn't run task (a Task has a maximum TTL of 24 hours)

The "Exit code" value can be viewed in the "Task output" box.

A few script examples:

$source = "https://www.bleachbit.org/download/file/t?file=BleachBit-4.4.2-setup.exe"
$dest = "C:\Windows\Temp\BleachBit-2.0-setup.exe"

Start-Sleep -m 30000

$client = New-Object System.Net.WebClient
$client.DownloadFile($source, $dest)

Start-Process msiexec.exe -Wait -ArgumentList '/I "$dest" /quiet'

Did this answer your question?