v5 regression: Get-ChildItem -LiteralPath -Recurse ignores -Include and gets all items
I have just installed Windows Management Framework (WMF) 5.0 RTM on my Windows
7 SP1 and tested it.
Get-ChildItem -LiteralPath -Include -Recurse started to
work differently in v5.
Get-ChildItem -Path $PSHOME -Include *.exe -Recurse
gets expected powershell.exe and powershell_ise.exe.
The same command with
-LiteralPath instead of
Get-ChildItem -LiteralPath $PSHOME -Include *.exe -Recurse
in PowerShell v5 RTM unexpectedly gets all items in
I cannot test this with previous versions right now (by the way,
PowerShell.exe -Version 2 seems to have the same issue in v5 RTM). But I
believe in PowerShell v3 and v4 this was not the case. I found this issue
because this command
Get-ChildItem -LiteralPath <path> -Include <some temp files> -Recurse | Remove-Item
tried to remove all files in
<path> instead of specified temp files.
This command used to work work as expected before installing v5 RTM.
Here is confirmation from Stack Overflow:
Roman Kuzmin commented
N.B. It works as expected in PS v5 Preview. So something changed in exactly the latest v5 RTM.