When powershell.exe is invoked to run a script it can occasionally start the OS process but silently stall before executing
any script content — typically due to Group Policy, antivirus, or other startup hooks that block or hang the PowerShell host.
Tentacle had no way to distinguish this from a legitimately long-running script, so affected deployments would hang indefinitely
with no useful error.
The startup detection mechanism lets Tentacle detect and report when PowerShell starts but never executes the script body.
Detection is opt-in. To enable it, include the following marker comment somewhere near the top of your script body (before any code you want to run):
# TENTACLE-POWERSHELL-STARTUP-DETECTIONWhen Tentacle bootstraps the script it replaces this marker with generated detection code. Scripts that do not include the marker are completely unaffected.
When the marker is present, Tentacle:
- Writes a
.octopus_powershell_should_runfile to the script workspace before launching PowerShell. - Replaces the marker with generated PowerShell that, at the point it executes:
- Exclusively creates a
.octopus_powershell_startedsentinel file. - Verifies the
.octopus_powershell_should_runfile still exists. - Exits with code
-47if either check fails (meaning the monitor already concluded PowerShell never started).
- Exclusively creates a
- Runs a monitoring task concurrently with script execution. If the sentinel file is not created within the startup timeout the monitor:
- Creates the sentinel itself (so any late-starting PowerShell process will exit immediately).
- Deletes the should-run file (so any late-starting process that somehow missed the sentinel will also exit).
- Returns exit code
-47(PowerShellNeverStartedExitCode) with a "process did not start within…" message written to the task log.
The default timeout is 5 minutes. It can be overridden by setting the environment variable:
TentaclePowerShellStartupTimeout=<TimeSpan>
For example, 00:02:00 for a 2-minute timeout.
Currently scoped to powershell.exe.