This completes in 2.3 minutes on LOCALSERVER:
A: measure-command {$x = invoke-command {gci -recurse "C:\"}}
This completes in 38.4 minutes on LOCALSERVER:
B: measure-command {$x = invoke-command -comp LOCALSERVER {gci -recurse "C:\"}}
Why is B so much slower? Is it because the "output is being serialized to XML and then reconstituted into objects again", as explained here, with B but not A? Or is something else going on?
LOCALSERVER runs Windows 2008R2 with PS v3. In both cases $x.count
is 98973.
I was wondering about changing an existing script to use PSRemoting for file searches on remote servers. I thought the searches might finish sooner with gci running on the remote target. In a handful of tests, the searches actually ran much longer with PSRemoting. I'm asking about the loopback scenario only because it seemed like the simplest case; I saw similar results with remote servers. So I'll stick with UNC path searches like this:
gci -recurse \\REMOTESERVER\C$\folder
...unless these results seem odd, and some adjustment to my remoting configuration or syntax might offer a big performance boost?