Creating and managing tasks
A task is a PowerShell item that checks one thing on a computer and corrects it when the check fails. This page covers where a task can run, how to create one, and how to find the fault when a task misbehaves.
What a task is
Software items install applications. A task covers everything else: a setting, a policy, a clean-up job, a piece of information you want collected. A task does not have to install anything.
Every task has two parts.
- The check. A script that answers one question: is this computer already as it should be?
- The correction. A script that makes it so.
A task can also report the current value, which is useful when you want to see a setting without judging it.
A task takes effect through a deployment. A task deployment is Enforced: in each maintenance session the check runs, and if it fails the correction runs, and then the check runs again. A task can also be checked without being changed, when you want to know where computers stand before you alter anything.
Where a task can run
When you create a task you choose where its script runs. The choice decides what the script can reach.
| Where it runs | Use it for | Limits |
|---|---|---|
| On the computer, as the system account | Computer-wide settings and anything that needs full local rights | Cannot show anything on screen |
| On the computer, as the person logged on | Settings that belong to one person | Has only that person's rights, and needs someone to be logged on |
| On the Overseer server, directing the computer | Work that spans several steps or several computers | Reaches the computer only through the commands Overseer provides |
| On the Overseer server only | Work against a cloud service | Cannot touch the computer at all |
Creating a task
- 1Open Library, then Tasks, and create a new task.
- 2Give it a clear, specific name. Add a description if the name does not say everything.
- 3Choose where the script runs.
- 4Write the check and the correction in PowerShell.
- 5Add any parameters the task needs. Each parameter has a name, a type and a description, and can have a default value and validation rules.
- 6Make sure the check returns true when the computer is as intended and false when it is not. This is how Overseer decides whether the task succeeded.
- 7Save the task. It is now available to deployments.
To use it, open Deployments, press New deployment and choose the task.
A worked example
This task keeps the Windows Time service set to start automatically. The check returns true when the setting is already correct:
(Get-Service -Name 'W32Time').StartType -eq 'Automatic'
The correction makes the change:
Set-Service -Name 'W32Time' -StartupType Automatic
After the correction runs, Overseer runs the check again. The item is marked Compliant only when that second check passes.
Managing tasks
Tasks marked Global are built in. Tasks marked Local are yours. Open a Local task from Library, then Tasks, to change its script, its parameters or where it runs.
Writing tasks that last
- Make them safe to repeat. A Required task runs in every session. Running it twice must leave the computer the same as running it once.
- Use parameters. One task with a parameter serves many clients. A value written into the script serves one.
- Handle errors. Catch the failures you expect and say what went wrong.
- Write to the log. Output from the script appears in the session, where it helps the next person.
- Comment the script. Explain anything that is not obvious.
- Start small. Try a new task on one computer before you aim it at many.
When a task does not behave
- Read the session log. Open the session and look at the output for that action.
- Run it in the Script Editor. Try the script against a test computer and watch what it returns.
- Check where it runs. A script that needs full rights fails as the person logged on. A script that changes a person's settings does nothing useful as the system account.
- Add diagnostic output. Print the values the check is comparing.
- Split it up. Break a large task into smaller tasks that each do one thing.