How it works
- Write the script or pick a .ps1 file; it uses PowerShell 7 when installed and Windows PowerShell otherwise, unless you choose one.
- Pass routine values under Values, read in the script as $env:KR_name, or as arguments, read as $args; nothing is ever pasted into the code itself.
- It runs hidden, without your profile, with a time limit and a memory limit, and anything it started is stopped when it ends.
- Outputs include the exit code, the output and error text, its lines, and parsed JSON when the script printed JSON with ConvertTo-Json.
- Script steps stay off until Allow script steps is turned on under Settings ▸ Advanced, and a dry run skips this step.
Routines that use it
Free up disk space
Every … 7 days, Run PowerShell clears an old cache folder and Script result checks that it succeeded.
Report your battery health
A Hotkey runs a script that prints battery info as JSON, and Show banner shows the numbers it returned.
Imported routines stay safe
A routine shared by a friend that contains a script stays off until you review and approve it.
Settings
| Setting | What it does |
|---|---|
| Source | Write the script here, or run a .ps1 file. |
| Script | The PowerShell code. Values from the routine aren't pasted in here: add them under Values and read them as $env:KR_name. |
| File | The .ps1 file to run. |
| Values | Values for the script, by name. The script reads each as $env:KR_<name> (for example $env:KR_folder). |
| Arguments | Arguments for the script, one per line. The script reads them as $args. |
| Working folder | The folder the script starts in. Empty: your user folder. |
| Editionadvanced | Which PowerShell runs it. Automatic uses PowerShell 7 when it's installed, else Windows PowerShell. |
| Timeout | The script is stopped, with everything it started, after this long. |
| Fail on erroradvanced | Fail the step when the script ends with an exit code other than 0. |
| Memory mb | The most memory the script and everything it starts may use together. |
Good to know
- The script can't ask for input while it runs; anything waiting for typed input fails instead of hanging.
- Long-running programs that should outlive the routine belong in Open app.
Questions
- How do I run a PowerShell script at startup or on a schedule?
- Use When KeyRoutines starts or At a time with a Run PowerShell step pointing at your .ps1 file. Turn on Allow script steps under Settings ▸ Advanced first.
- Is it safe to run routines from other people that contain scripts?
- An imported routine with a script stays off until you approve it, and the preview marks it clearly as running a script. Any later change to the script step turns it off again until you approve it.