Ты прав. Это похоже на ошибку. Работает в подкаталогах.
gci -path c:\windows -directory -exclude winsxs
В osx в 6.2.3 выдает странное сообщение:
gci -path / -directory -exclude var
gci : Cannot process argument because the value of argument "path" is not valid. Change the value of the "path" argument and run the operation again.
At line:1 char:1
+ gci -path / -directory -exclude var
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ChildItem], PSArgumentException
+ FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.GetChildItemCommand
Или так в windows пс 5.1 - 7:
dir Microsoft.PowerShell.Core\FileSystem::C:\ -exclude windows
dir : Cannot process argument because the value of argument "path" is not valid. Change the value of the "path" argument and run the operation again.
At line:1 char:2
+ dir Microsoft.PowerShell.Core\FileSystem::C:\ -exclude windows
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ChildItem], PSArgumentException
+ FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.GetChildItemCommand
Вот обходной путь, но только для powershell 6 и 7:
get-item c:\ | get-childitem -exclude windows