如何让 PowerShell Core 以递归方式计算 OneDrive 同步目录中的文件?

How to Get PowerShell Core to Count Files in OneDrive Sync Directories, Recursively?

我尝试在 OneDrive 同步目录上的 PowerShell Core (v6.2.2) 中使用以下命令,但它只会 return 根目录中的目录计数。它在 OneDrive 同步文件夹之外的其他目录中运行良好。

Get-ChildItem -Recurse -Directory | %{ "$($_.FullName) $((gci $_.FullName).Count)" }

解决方法是使用 -FollowSymlink 参数。

Get-ChildItem -Recurse -Directory -FollowSymlink | %{ "$($_.FullName) $((gci $_.FullName).Count)" }

我发现以下拉取请求有助于回答问题。 https://github.com/PowerShell/PowerShell/pull/9509