offload a command inside my module

Welcome Forums General PowerShell Q&A offload a command inside my module

  • This topic has 3 replies, 2 voices, and was last updated 1 month ago by
    Participant
    .
Viewing 3 reply threads
  • Author
    Posts
    • #232945
      Participant
      Topics: 5
      Replies: 7
      Points: 47
      Rank: Member

      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.

    • #232960
      Participant
      Topics: 5
      Replies: 2373
      Points: 6,011
      Helping Hand
      Rank: Community MVP

      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.

    • #233353
      Participant
      Topics: 5
      Replies: 7
      Points: 47
      Rank: Member

      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?

    • #233383
      Participant
      Topics: 5
      Replies: 2373
      Points: 6,011
      Helping Hand
      Rank: Community MVP

      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.

Viewing 3 reply threads
  • You must be logged in to reply to this topic.