Keeping Remote Programs Running

by Feb 6, 2012

When you use PowerShell Remoting (like the Enter-PSSession cmdlet) to connect to another machine and then start a program using Start-Process, the program is automatically associated to your remote session. Once you leave and discard your remote session, all programs you previously started with Start-Process will also be killed.

While this is a reasonable cleanup strategy for most scenarios, you sometimes want programs to continue to run, even after you discarded your remoting session. To do that, use WMI rather than Start-Process to run the program:

(Invoke-WmiMethod Win32_Process Create calc.exe).ReturnValue -eq 0

Twitter This Tip! ReTweet this Tip!