offload a command inside my module

Hi

I’m creating a module for usermanagement. One function forces a sync to both cloud-providers.

When I call the function, the first provider anwser after less then 30 seconds with success, this means it has started the sync. The function will go further.

The second provider anwsers with the whole logging for the next 2 minutes, what I don’t need. It’s started from an exe.

Can I offload this command (or other commands) to another thread so that function will go faster and I don’t see the logging? All the logging is captured with another process.

Of course. You can use Start-Process to start an independend process or - if you like to collect the results later - you could use a Powershell job with Start-Job.

Thanks, Olaf.

I started reading about Start-Process and Start-Job. My choice goes to Start-Job and the -AsJob parameter for Invoke-Command and others.

Is it right that Start-Process is still interactive?

I’m not completely sure what you mean. I’d say it depends on the process you start. There are executables giving away the control immediately after they started and some keep the control until they’ve finished their work and end themself. You can control this behaviour using the Start-Process parameter -Wait.