Hi Emily,

PowerShell Background Jobs created on the local computer are tied to the
console that created them, in that two separate powershell.exe windows
cannot see the each other's jobs. Since they are 'background', control is
returned immediately to the caller when they are created. In your examples
below, Start-Job creates the job and completes successfully. The Job starts
running and doing whatever its doing. PowerShell sees this as the last
command to run and exits. When PowerShell exists, any running process or
threads are aborted, and thus your Job as well. Puppet sees a success exit
code from PowerShell and closes the run. You could use Wait-Job to wait for
the job to finish, but that would block execution until that job finished,
which is contrary to the goal I assume you have - running a PowerShell
script concurrently while other parts of a Puppet manifest execute.

I don't know of a way to make this work for you for Start-Job. If there is
a need to run something while other things run, that starts to enter the
arena of the Puppet Orchestrator. I might be able to help with more of an
idea of what you are trying to accomplish.



On Mon, Apr 16, 2018 at 11:35 AM, Emily Gribble <emilygribb...@gmail.com>
wrote:

> I am trying to use a puppet module to kick off a powershell script in the
> background. Start-Job appears to be the best choice for this, but the
> combination of puppet and Start-Job is not producing the results I would
> expect. Here are some examples of different options I have tried (all three
> work from the powershell command line on the node in question). All of
> these execs return "executed successfully," but fail to actually run the
> script. Any ideas?
>
>
> exec { 'foo':
>   command => "Start-Job C:/Windows/foo.ps1",
>   provider => "powershell"
> }
>
>
> exec { 'foo':
>   command => "Start-Job -ScriptBlock {C:/Windows/foo.ps1}",
>   provider => "powershell"
> }
>
>
>
> exec { 'foo':
>   command => "Start-Job -File C:/Windows/foo.ps1",
>   provider => "powershell"
> }
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/puppet-users/81ddfefb-ea11-4cc5-bd08-05a62db0fa5e%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/81ddfefb-ea11-4cc5-bd08-05a62db0fa5e%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
James Pogran
Senior Software Engineer, Windows
james.pog...@puppet.com | @ender2025 <https://twitter.com/ender2025>
Puppet <https://puppet.com/>. *The shortest path to better software*

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CABCjNrUapYSXS5%3DXFh1mQxy_zfzqy4LHy%3D2HKpcD_-tmNsRuuA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to