DIR或者GCI在Powershell中速度慢,但在CMD中速度很快.有什么方法可以加快速度吗?
在CMD.exe中,在亚秒延迟之后,响应速度与CMD窗口可以跟上的速度一样快
dir \\remote-server.domain.com\share\folder\file*.*
Run Code Online (Sandbox Code Playgroud)
在Powershell(v2)中,经过40秒以上的延迟,这会以明显的缓慢响应(可能每秒3-4行)
gci \\remote-server.domain.com\share\folder\file*.*
Run Code Online (Sandbox Code Playgroud)
我正在尝试扫描远程服务器上的日志,所以可能有更快的方法.
get-childitem \\$s\logs -include $filemask -recurse | select-string -pattern $regex
Run Code Online (Sandbox Code Playgroud) 当使用 UNC 路径(例如:)时,我可以在从 UNC 路径使用命令( )\\machine\share\dir时获取文件列表,但如果我尝试,我会得到一个空列表(不是错误,只是没有项目)。我以为PS是建立在.NET框架之上的。有谁知道为什么.NET方法返回空列表时会使用 UNC 路径?dirGet-ChildItem[System.IO.Directory]::GetFilesGet-ChildItemGetFiles