The Script library is where you keep the scripts you run on your devices. Upload a .sh, .py or .ps1 script once and run it on any compatible device.
Overview
Supported script types:
| Extension | Platforms | Notes |
|---|---|---|
.sh |
macOS, Linux | Must run under /bin/sh, /bin/bash, or /bin/zsh. |
.py |
macOS, Linux | Must start with a shebang that includes python (for example, #!/usr/bin/env python3). |
.ps1 |
Windows | Runs in PowerShell. |
Each script is capped at 1 MiB.
How to use
Open the Script library
- In the Factorial IT console, open Device Management.
- Select the Scripts tab.
- Select the Script library sub-tab. Each row shows a script's name, type and actions.
Add a script
- Click Add a script.
- Provide the script in one of two ways:
-
Drag and drop a
.sh,.pyor.ps1file onto the upload area. The name, platform and contents are filled in for you. - Fill in the fields by hand: choose a platform, type a name ending in the right extension, and paste the script into the editor.
-
Drag and drop a
- Click Save.
The Platform selector controls the extension. Changing the platform rewrites the extension in the name. Typing a name that ends in a matching extension changes the platform. Both fields can be edited freely; they only stay linked when the other one leaves no doubt.
Edit a script
- On the script's row, open the actions menu and select Edit.
- Change the script in the editor.
- Click Save. The button stays disabled until you change something.
Only the contents can be edited. The name and platform are locked, because renaming would change the script type. To rename a script or change its type, delete it and create a new one.
Download a script
On the script's row, open the actions menu and select Download. The file keeps its original name and extension.
Delete a script
- On the script's row, open the actions menu and select Delete.
- Confirm in the dialogue.
Earlier runs stay in each device's script history, because Factorial IT keeps the name and contents used at the time. Runs that had not finished yet are marked cancelled.
Validation rules
Before saving, Factorial IT checks that:
- The name ends in
.sh,.pyor.ps1. - The contents are 1 MiB or less.
- A
.pyscript begins with apythonshebang, for example:#!/usr/bin/env python3 print("Hello from Factorial IT") - A
.shscript that declares a shebang uses a supported interpreter, such as#!/bin/bashor#!/usr/bin/env bash.
If a check fails, Save stays disabled and the field at fault explains why.
Permissions
| Action | Required permission |
|---|---|
| View the library, download a script | MDM_READ |
| Add, edit, or delete a script | MDM_WRITE |
Without the right permission, the action is still shown but disabled, and a tooltip tells you why.
Tips and Best Practices
- Drag and drop the file. It fills in the name, platform and contents for you and avoids extension mistakes.
-
Always add a shebang to Python scripts. Without
#!/usr/bin/env python3or similar, the script cannot be saved. - Download before you delete. Deleting cannot be undone, and you may want the file later.
- Delete and recreate to change type. Name and platform are locked once a script is saved.
Troubleshooting and FAQ
Troubleshooting
Save is disabled when adding a script. A validation rule failed. Read the message under the field: usually a wrong extension, a missing python shebang, an unsupported shell, or a file over 1 MiB.
Save is disabled when editing a script. You have not changed the contents yet.
I cannot rename a script. Name and platform are locked. Delete the script and add it again with the new name.
An action is greyed out. You are missing MDM_READ or MDM_WRITE. Hover over it to see which.
FAQ
-
Which platforms can run scripts from the library?
macOS and Linux with.shand.py, and Windows with.ps1.
-
What happens to past runs when I delete a script?
They stay in each device's script history with the name and contents used at the time. Runs that had not finished are cancelled.
-
How big can a script be?
Up to 1 MiB.
-
Can I change a script's platform after saving it?
No. Delete it and create a new one.