alternative for using powershell pipeline

Welcome Forums General PowerShell Q&A alternative for using powershell pipeline

This topic contains 0 replies, has 1 voice, and was last updated by  Forums Archives 6 years, 10 months ago.

  • Author
    Posts
  • #5517

    Member
    Points: 0
    Rank: Member

    by arvindrajan92 at 2013-02-06 02:22:22

    hi,

    i have been using powershell lately and i found that execution using powershell pipeline is very slow. for example, execution of the code below:

    New-RDRemoteApp -ErrorAction stop -DisplayName "utorrent" -filepath "C:\Program Files (x86)\uTorrent\uTorrent.exe" -collectionname "quicksessioncollection" –connectionbroker win-serverpark.serverpark.net

    The code above adds a remoteapp and takes an average time about 20seconds. if i execute 2 similar commands at 1 go, it takes about 40 seconds and so on.

    I am sure there must be a way to make this execution quicker, as in by not using powershell pipeline

    Anyone with suggestion? With example would be very helpful

    Thanks in advance 🙂

    by DonJ at 2013-02-06 13:34:20

    Well... every command runs in a pipeline. Always. That's how the shell works. But this:


    Get-Service -Name BITS | Stop-Service

    Is somewhat different from this:


    $service = Get-Service -Name BITS
    Stop-Service -inputobject $service

    Which is different yet from:


    Stop-Service -Name BITS

    You're saying that you have one command that runs in 20 seconds, versus two commands that take 40 seconds. So... use the 20-second command would be my suggestion?

    (FYI – as this is not an AD question, I will be moving your topic to an appropriate forum)

    by arvindrajan92 at 2013-02-07 18:41:30

    okay. does that mean i could execute two 20-second command in 20 seconds instead of 40 seconds if i use the the example code u showed above? which means multithreading?

    sorry for the wrong forum. yes, thanks a lot

    by arvindrajan92 at 2013-02-07 18:50:18

    no, what i meant was that the command in my first post publishes a new remoteapp. but when i want to publish 2 apps, i will have to run the code same code twice, whereby the 2nd code waits till the 1st code is done.

    what im asking is that is there a way to run both of them simultaneously? like multithreading or in parallel?

    by DonJ at 2013-02-07 18:56:39

    Ah. No. PowerShell is single threaded. But you could launch each as a job, which would run them in parallel using separate threads. Ish.

The topic ‘alternative for using powershell pipeline’ is closed to new replies.