简体   繁体   English

powershell remoting:很慢

[英]powershell remoting: very slow

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. 如果我从solaris服务器ssh到美国服务器,ssh连接速度非常快,例如删除文件很快就能完成。

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. 但是为什么PowerShell远程处理如此慢,在我进入远程会话后,然后删除一个项目,完成需要10秒以上。

Enter-PSSession -computerName test
remove-item 'C:\20010101.xls' 

running the following command also takess more than 5 seconds. 运行以下命令也需要5秒以上。

[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. 我猜你看到的大部分时间都是由于远程PowerShell会话的启动造成的。

Rather than use Enter-PSSession try using Invoke-Command. 而不是使用Enter-PSSession尝试使用Invoke-Command。 It still initializes a remote PS session but you don't get all the console overhead. 它仍然初始化远程PS会话,但您没有获得所有控制台开销。

Invoke-Command -Computer test -ScriptBlock { [Environment]::UserDomainName + "\\" + [Environment]::UserName+" on "+[Environment]::MachineName } 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. 请记住,PowerShell和WinRM代表您做了很多事情,因为您的所有输出都被序列化为XML,然后再次重构为对象。 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. 关于PowerShell的最好的事情之一,一切都是一个对象,是什么使它通过ssh / bash / cmd等执行类似的操作时变慢。这都是关于权衡。

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 --Greg

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM