by arvindrajan92 at 2013-02-06 02:22:22
hi,by DonJ at 2013-02-06 13:34:20
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
Well… every command runs in a pipeline. Always. That’s how the shell works. But this:by arvindrajan92 at 2013-02-07 18:41:30
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)
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?by arvindrajan92 at 2013-02-07 18:50:18
sorry for the wrong forum. yes, thanks a lot
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.by DonJ at 2013-02-07 18:56:39
what im asking is that is there a way to run both of them simultaneously? like multithreading or in parallel?
Ah. No. PowerShell is single threaded. But you could launch each as a job, which would run them in parallel using separate threads. Ish.