title: PowerShell Layered Script - Passing error codes for dependencies
body: <p>I have started using a monitoring system called Cronitor that wraps scheduled task executions in their EXE.</p>
  <p>Cronitor.exe exec (UID for monitor) &quot;Path to script/executable&quot;.</p>
  <p>Adding to that, I am working on synchronizing some of our scheduled tasks that are dependent on each other.</p>
  <p>The problem I have is that because the executable wraps scripts/programs/tasks, the error code returned to Windows task scheduler is always 0 because it's not passed in their exe.</p>
  <p>My work around is to layer powershell scripts (which I am not super proficient in yet).</p>
  <p>So Action 1 calls &quot;StartAction.ps1&quot;</p>
  <p>Inside that ps1 script,</p>
  <p>Start-Process &quot;Path to cronitor&quot; -ArgumentList &quot;Crontior arguments and path to ps1 that initiates exe for action 1&quot; -Wait
  Start-Process &quot;Path to cronitor&quot; -ArgumentList &quot;Crontior arguments and path to ps1 that initiates exe for action 2&quot;</p>
  <p>The issue I am running into is the same for trying to stop the scheduled task if the process fails in action 1. I need to pass the error code (1) up through a pipeline to the initiating script so it knows to stop.</p>
  <p>Is that even possible, or are there other solutions I am missing?</p>