PSRemoting performance overhead with get-childItem

南笙酒味 提交于 2019-12-05 17:16:56

As you mentioned, the time required to invoke the command remotely must also take into account the time needed to deserialize any given object you return from your remote pipeline (in your case the whole tree of FileSystemInfo of the C drive). I would suggest to limit the number of objects you serialize and deserialize over the network and, while comparing performances of your servers, perhaps consider the time taken from within the machine you are running the code on:

Invoke-Command -comp LOCALSERVER { Measure-Command { gci -recurse "C:\" } }

Somewhere in between returning full objects and just getting a string list, if the remote system is running V3, you can get a shallow deserialization via json:

ConvertFrom-Json (icm -comp server { gci -rec c:\ | convertto-json -Depth 1})

Edit:

Converting to/from csv gets you a (shallow) deserialized object, and actuall seems to run faster than out-string:

ConvertFrom-csv (icm -comp server { gci -rec c:\ | convertto-csv})

Yes, you're correct about the overhead of serializing/deserializing the FileInfo and DirectoryInfo objects over the wire. If you don't care about getting real objects, do something like this:

icm -comp server { gci -rec c:\ | out-string }

It should be an order of magnitude faster, at least.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!