Powershell 5 Get-ChildItem LiteralPath不再适用于Include

Mar*_*ser 8 powershell powershell-5.0

现在我使用PowerShell 5.0.10586.0更新到Windows 10 TH2 Build 10586

现在我遇到了Get-ChildItem的问题

$files = Get-ChildItem -LiteralPath $path -Force -Recurse -Include *.txt
Run Code Online (Sandbox Code Playgroud)

这将返回$ path中的所有文件,即使它们不是.txt.这在更新之前有效.当我改为

$files = Get-ChildItem -Path $path -Force -Recurse -Include *.txt
Run Code Online (Sandbox Code Playgroud)

它又有效了.但这不是我想要的.这是一个错误还是我做错了什么?

Bac*_*its 5

就个人而言,我从不使用-Include-Exclude不再使用.我总是穿透Where-Object.我不知道作者-Include-Exclude疯子是否疯了,或者是否存在底层.Net提供商的问题,但是他们的表现很糟糕.

我在5.0.10240.16384.

gci -Path $path -Include *.txt -Force
Run Code Online (Sandbox Code Playgroud)

什么都不返回

gci -LiteralPath $path -Include *.txt -Force
Run Code Online (Sandbox Code Playgroud)

返回所有内容$path.

gci -LiteralPath $path -Include *.txt -Force -Recurse
gci -Path $path -Include *.txt -Force -Recurse
Run Code Online (Sandbox Code Playgroud)

两者都返回*.txt $path和所有子文件夹.

那么应该采取什么样的行为呢?-Recurse国旗是否修改了如何-Include运作?我不知道.我不再关心了.我不打算处理那种行为.我只是用这个:

gci -Path $path -Recurse -Force | Where-Object { $_.Extension -eq '.txt' }
Run Code Online (Sandbox Code Playgroud)

我依靠Get-ChildItem枚举文件和文件夹,就是这样.只要给我对象,我就会过滤它们.像所有旧的Remove-Item -Recurse错误一样,那里的某些东西根本不像人们期望的那样工作.