If I ssh from a solaris Server to a US server, the ssh connection is very fast, such as delete a file can complete very soon.
But why powershell remoting is so slowing, after I entered the remote session, and then remove an item, it takes more than 10 seconds to complete.
Enter-PSSession -computerName test
remove-item 'C:\20010101.xls'
running the following command also takess more than 5 seconds.
[Environment]::UserDomainName + "\" + [Environment]::UserName+" on"+[Environment]::MachineName
One of the reason I am using remoting is that remote desktop connection is slow as it has to transfer large amount of data from the server to local. And for remoting, I am hoping it only transfer text which is very little amount of data so I expect it will be much faster than remote desktop connection. But the fact is that it is also very slow.
Any way to enhance performance, or find out where most of the time goes to?
Daniel,
I'm guessing most of the time delay you're seeing is the due to the startup of the remote PowerShell session.
Rather than use Enter-PSSession try using Invoke-Command. It still initializes a remote PS session but you don't get all the console overhead.
Invoke-Command -Computer test -ScriptBlock { [Environment]::UserDomainName + "\" + [Environment]::UserName+" on "+[Environment]::MachineName }
Keep in mind that PowerShell and WinRM are doing a lot on your behalf because all your output is being serialized to XML and then reconstituted into objects again. One of the best things about PowerShell, everything is an object, is what makes it slower when performing similar actions via ssh/bash/cmd etc. It's all about the tradeoffs.
When I'm doing tasks that I know will take a while I try to schedule them as jobs and move on to other things.
--Greg
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With