Using Puppet and PowerShell: Long running scripts with good manifest logging

I have complex PowerShell scripts that I would like Puppet manifests to govern. I use a PowerShell plugin. I can have Puppet manifests transfer a PowerShell script and run it. The relevant messages of a Puppet Agent running and associated logs on the Puppet Agent server and Puppet master server can show a success well before the PowerShell script has finished. Is there a way or trick to getting a Puppet manifest to not show such quick “successes” and wait for the entire PowerShell script to actually finish? The solution may be more of a PowerShell fix than a Puppet fix.

What is the behavior of launching an exe or Powershell in Puppet? Does it wait until Powershell.exe completes before continuing? It also matter what you doing in the Powershell code as well. Are you calling other EXE’s or starting sub-processes in the Powershell code? My assumption is something is not set to wait until completion. Typically, Start-Process is used for EXE’s because we can specify the -Wait parameter to have it not run any more code until the spawned process is complete. I also found this if it helps that Powershell is producing a non-terminating error that isn’t being handled by Puppet: