Windows Script Configuration

A policy configuration for PowerShell scripts is available in Relution for managed Windows devices. In the selection, the configuration is called Script and can be added to Windows policies as usual. It is executed by the Windows Companion →, which must be installed on the device for this purpose.

However, in preparation, the PowerShell script to be distributed must be stored in the menu under Scripts.

The script is not implemented by Relution, so no guarantee is given for any damage. The script should be inspected carefully before it is applied to a device. In addition, Relution cannot provide support for any errors that may occur or for the creation of the scripts.

Policy configuration

The policy offers, besides the selection of the desired script, various other configuration options. At least one of the two execution types (event based or time based) must be enabled. Both are disabled by default and can be combined.

The configuration can be added to a policy multiple times, each with its own script. In the configuration list of the policy, it appears under the name of the selected script.

Script to execute

The previously stored script must be selected here under Choose script to execute. Only one script per configuration can be selected at a time; PowerShell scripts for Windows are available for selection. Placeholders in the script content are replaced for each device before delivery (see Advanced placeholders →).

The Select Script button opens the Choose script dialog with the columns Name, Description, Type and Scope; the Search field filters the list by name and description. A script is marked via the radio button in its row and applied with Confirm. The selected script appears below the button and can be removed again via its cross icon.

Besides the organization’s own scripts (scope Local only), scripts that have been shared across organizations in the Global organization or in the parent meta organization are available for selection (From Global or From Meta, and Shared in the sharing organization itself). In the Global organization and in meta organizations, only shared scripts are offered. How scripts are shared is described in Publish scripts globally →.

When a saved configuration is opened, the form loads the current state of the script. If the script no longer exists, the selection is empty and has to be set again before the configuration can be saved. If the policy belongs to another organization, the form does not show the selected script; its name is still shown in the configuration list of the policy.

Event based execution

The Execute script for the following events on the device switch makes the execution of the script dependent on certain events on the device. As long as the switch is disabled, the fields below it are locked. When it is enabled, at least one of the following events must be selected under Device events; several events can be combined, none is preselected:

  • Device started
  • User logged in – the optional field Limit login trigger to a specific user restricts execution to one user; it only appears when this event is selected. The user’s SID as well as the formats Domain\Username and Username are supported. If the field is left empty, the script is executed when any user logs in. If the event is deselected again, the entry is discarded when saving.
  • User logged out – on shutdown, only a few seconds remain for execution; after that, the device cancels it.

Time based execution

The Execute script in the following period of time switch executes scripts regularly at specific times on the target device. As long as the switch is disabled, the fields below it are locked; when it is enabled, all three fields are required.

FieldDescriptionDefault
Repeats onDays of the week on which the script is executed. Each day from Monday to Sunday has its own button; several days can be combined.no day
Start timeTime of execution on the selected days.8:00 AM
Time zoneTime zone to which the Start time refers. 29 time zones are available.(UTC +01:00/+02:00) Europe/Paris

Restrict execution

The execution of the script can also be prevented or the behavior adjusted under certain circumstances. On the device, the execution runs as a task in the Windows Task Scheduler; the following options apply to this task.

FieldDescriptionDefault
Disallow execution when running on batteriesThe execution is not started while the device is running on battery power.disabled
Stop execution when switching to battery powerA running execution is stopped as soon as the device switches to battery power.disabled
Wake device for script executionThe Windows Task Scheduler wakes the device when the execution is due.disabled
Hide script execution task on deviceThe script execution task is hidden in the Windows Task Scheduler interface.disabled
Allow to start the script execution on demandAllows the script execution to be started manually on demand, independently of the configured events and schedule.disabled

Example: Run a script at login and weekly

A PowerShell script Clean up temp folder, stored under Scripts, is to run every time the user EXAMPLE\kiosk logs in and additionally every Friday at 6:00 PM, but not start while the device is running on battery power:

  • Choose script to execute: Clean up temp folder
  • Execute script for the following events on the device: enabled
  • Device events: User logged in
  • Limit login trigger to a specific user: EXAMPLE\kiosk
  • Execute script in the following period of time: enabled
  • Repeats on: Fri
  • Start time: 6:00 PM
  • Time zone: (UTC +01:00/+02:00) Europe/Paris
  • Disallow execution when running on batteries: enabled

After the policy has been published, the script is executed on the assigned devices every time EXAMPLE\kiosk logs in and on Fridays at 6:00 PM (CET/CEST), provided the device is not running on battery power at that moment.

How helpful was this article?