Schedule a PowerShell Script
PowerShell runs cross-platform as pwsh. On Linux/macOS call it from cron; on Windows use Task Scheduler. Use -File for a script path and set an execution policy that allows it to run unattended.
From cron (Linux/macOS)
0 * * * * /usr/bin/pwsh -NoProfile -File /home/user/task.ps1 >> /home/user/task.log 2>&1 runs the script hourly. Find pwsh with which pwsh.
From Task Scheduler (Windows)
schtasks /create /tn "PSJob" /tr "powershell.exe -NoProfile -ExecutionPolicy Bypass -File C:\task.ps1" /sc hourly.
-File vs -Command
Use -File script.ps1 to run a script file; use -Command only for an inline one-liner. Add -NoProfile so the job isn't slowed or broken by a user profile.
FAQ
How do I run a PowerShell script from cron?
Install PowerShell (pwsh) and add 0 * * * * /usr/bin/pwsh -NoProfile -File /path/task.ps1 to your crontab.
How do I schedule a PowerShell script on Windows?
Use Task Scheduler: schtasks /create /tn "PSJob" /tr "powershell.exe -ExecutionPolicy Bypass -File C:\task.ps1" /sc hourly.
Should I use -File or -Command?
Use -File for a .ps1 script path and -Command only for an inline statement. Add -NoProfile for reliable unattended runs.