Script Execution Guide
Execute PowerShell, Bash, or CMD scripts across your device fleet.
Creating Scripts
Via Dashboard
- Navigate to Scripts → My Scripts
- Click New Script
- Enter script details:
- Title: Script name (e.g., "Update Windows")
- Description: What the script does
- Content: The actual script code
- Interpreter: Select execution environment
Supported Interpreters
| Interpreter | Platform | Use Case |
|---|---|---|
| PowerShell | Windows | Windows administration, system queries |
| CMD | Windows | Legacy batch commands, system utilities |
| Bash | Linux/macOS | Shell scripting, system administration |
Script Content Example
Windows - PowerShell
# Get system information
$computerSystem = Get-ComputerInfo
$computerSystem | Select-Object CsModel, CsSystemType, WindowsVersion | Format-List
Linux - Bash
#!/bin/bash
# Check disk usage
df -h
echo "---"
# Check memory
free -h
Saving and Managing Scripts
Save Script
- Click Save
- Script is stored in the database
- Becomes available for deployment
Edit Script
- Navigate to Scripts → My Scripts
- Click the script
- Edit content
- Click Save
Delete Script
- Navigate to Scripts → My Scripts
- Click the script
- Click Delete
- Confirm deletion
Executing Scripts
On-Demand Execution
Single Device
- Go to Devices → Select device
- Click Execute Script
- Choose script from list
- Optionally adjust timeout (default: 300 seconds)
- Click Execute
- View real-time output
Device Group
- Go to Devices → Select group
- Click Execute Script on Group
- Choose script
- Confirm to execute on all devices in group
- Monitor job status
Monitoring Execution
During script execution:
- Real-time Output: See stdout as script runs
- Progress Indicator: Know how far along it is
- Status: Pending → Running → Completed/Failed
- Exit Code: Process return value (0 = success)
After Execution
Results are displayed:
- Output: Full stdout and stderr
- Exit Code: Process return value
- Duration: How long the script ran
- Timestamp: When execution started/ended
Scheduled Execution
Creating a Schedule
- Navigate to Scripts → Schedules
- Click New Schedule
- Select script
- Enter CRON expression
- Select target group
- Click Create
CRON Expression Guide
Basic format: minute hour day month weekday
Common examples:
0 9 * * MON- Every Monday at 9:00 AM0 */2 * * *- Every 2 hours0 0 * * *- Daily at midnight0 0 1 * *- First day of month at midnight30 2 * * 0-4- Weekdays at 2:30 AM
Enabling/Disabling Schedules
- Navigate to Scripts → Schedules
- Click the schedule
- Toggle Enabled
- Changes take effect immediately
Monitoring Scheduled Executions
- Click schedule
- View Execution History
- See results of past runs
- Check for failures or issues
Advanced Features
Output Capture
LabSync captures:
- Stdout: Normal output and results
- Stderr: Error messages
- Exit Code: Process return value
Example output:
Output:
---
5/19/2026 2:45:00 PM
Microsoft Windows [Version 10.0.19044]
---
Exit Code: 0 (Success)
Duration: 1.2 seconds
Script Templates
Common scripts ready to use:
System Update (Windows)
# Update Windows
Write-Host "Starting Windows Update..."
Start-Process -FilePath "C:\Windows\System32\cmd.exe" -ArgumentList "/c taskkill /IM explorer.exe /F; timeout /t 3; explorer.exe"
Write-Host "Restart scheduled for next maintenance window"
System Cleanup (Linux)
# Clean package manager cache
sudo apt-get clean
sudo apt-get autoclean
sudo apt-get autoremove
echo "Cleanup complete"
Hardware Inventory (Both)
# Windows
Get-ComputerInfo | Select-Object CsManufacturer, CsModel, CsNumberOfProcessors | Format-List
# Linux
lscpu
dmidecode
Next: Learn about Scheduling or Remote Desktop