Comparison9 min
Scheduled Job vs. Scheduled Task in PowerShell 7
PowerShell 7 can register a scheduled task but not a scheduled job. The job cmdlets load only in Windows PowerShell, where a job saves each run's output.
A script that runs with nobody watching, as a scheduled task or at boot, fails in ways your own session never shows, and reports success while it does.
A script that runs with nobody watching fails in two ways a console never shows. It runs in a context you didn’t test, and it reports success when it didn’t succeed.
The context first. A scheduled task that runs as SYSTEM has its own profile.
It doesn’t see a module you installed under your Documents folder, or AWS
credentials written to your own profile. Install AWS.Tools for all
users puts the modules where
SYSTEM finds them, and the 7 Days to Die backup
gives SYSTEM credentials of its own. Without a Start in value, the task runs in
C:\Windows\system32, so a script that works at your prompt fails in Task
Scheduler while the
task records 0x0. A console you open isn’t the task’s context, so check from
inside the task: a few lines at the top of its script write a log you read
afterwards.
Then the signal. After a failed cmdlet, $LASTEXITCODE still holds whatever
the last native program returned, often zero
(why $LASTEXITCODE misses cmdlet errors).
A script that exits 3 reaches its caller as 1 when it runs under
-Command "& 'script.ps1'", and as 3 under -File
(which exit code the caller gets).
Those three articles are the failure signals series.
Installing for every account is the same problem at sign-in. A setting under
HKCU lands in the hive of whoever runs the command, so showing file
extensions reaches every other
account through Active Setup at its next sign-in, and
VS Code installs for all users with its
installer’s own switches, because Server 2022 has no winget.
A game server is a long-running unattended job. SteamCMD exits 7 on its first
run whether or not the install worked, and can print Success! with exit code
0 without changing the build, so installing
it checks the executable
and updating only on a new build
reads the build ID again. The server starts at boot as a SYSTEM
task. Shutting
Windows down leaves an Azure VM Stopped and still billing for compute, so a VM
that starts daily and deallocates itself
turns off only when the schedule started that boot and nobody is playing. The
whole job, in order, is the 7 Days to Die server
series.
The habit that carries across: decide what proves a step worked before you run it, then break that check on purpose and confirm it fails.
13 articles
Comparison9 min
PowerShell 7 can register a scheduled task but not a scheduled job. The job cmdlets load only in Windows PowerShell, where a job saves each run's output.
Comparison3 min
LTS lets your scripts run for years on security fixes alone, while Stable trades that stability for new features and an upgrade every time a new LTS ships.
Guide22 min
Configure an Azure server VM to start itself daily, update Windows, and deallocate when idle, so it runs about an hour or two a day instead of 24/7.
Answer11 min
Under -File the caller receives the exit code your script chose; under -Command, any script code other than 0 or 1 reaches the caller as 1.
Troubleshooting18 min
Task Scheduler records the exit code of powershell.exe, not whether the script worked, so a script that hit an error and carried on is recorded as a success.
Guide13 min
Run a 7 Days to Die server from a Windows scheduled task with no time limit, and stop it over telnet so the shutdown finishes and the world is saved.
Guide11 min
Compare the buildid in the appmanifest with SteamCMD's app_info_print and run app_update only when they differ. Success! and exit code 0 prove nothing.
Guide9 min
SteamCMD and a dedicated server installed on Windows Server, checked by the success line, the executable and the build ID rather than the exit code.
Troubleshooting5 min
Cmdlets never set LASTEXITCODE, so after a failed cmdlet it still holds whatever the last native program returned, often zero.
Guide7 min
You end up with AWS.Tools in Program Files, where a task running as SYSTEM finds it; SYSTEM's module path never includes your Documents folder.
Guideupdated Oct 202622 min
The world lands in S3 every morning as an archive that restores onto a fresh server, and the task's result says whether that morning's copy arrived.
Guide4 min
Windows Server 2022 has no winget, but VS Code's own installer takes switches that install it for every account without showing a window.
Answer4 min
HideFileExt set to 0 shows file extensions for your account, and one Active Setup entry sets it for every account on the machine at its next sign-in.