-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Open
Labels
Area-FileSystem-Providerspecific to the FileSystem providerspecific to the FileSystem providerNeeds-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
PS> New-Item -Path '@flowtyped' -Type Directory
PS> Set-Location '@flowtyped/'
PS> New-Item -Path '@flowtyped' -Type File
PS> New-Item -Path 'flow-typed','build' -Type FileExpected behavior
`-Exclude` should filter only matching items and return the remaining files:
PS> "$pwd"
C:\@flowtyped
PS> Get-ChildItem . -Exclude '@flowtyped'
Directory: C:\@flowtyped
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 2/5/2026 6:51 AM 0 build
-a--- 2/5/2026 6:54 AM 0 flow-typedActual behavior
No items are returned when the excluded name matches the current directory name:
PS> "$pwd"
C:\@flowtyped
PS> Get-ChildItem . -Exclude '@flowtyped'
PS> # Nothing is returned
PS> Get-ChildItem . -Exclude '@flowtyped','build'
PS> # Nothing is returned
However, using `-Exclude` together with `-Name` produces the expected filtered results:
PS> Get-ChildItem . -Exclude '@flowtyped' -Name
build
flow-typed
PS> Get-ChildItem . -Exclude '@flowtyped','build' -Name
flow-typed
When using `Get-ChildItem` with the `-Exclude` parameter, no results are returned if one of the excluded names is identical to the current working directory name — even when other non-excluded files exist.
This behavior appears inconsistent because combining `-Exclude` with `-Name` returns the expected results.Error details
Environment data
Name Value
---- -----
PSVersion 7.5.4
PSEdition Core
GitCommitId 7.5.4
OS Microsoft Windows 10.0.19045
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0Visuals
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Area-FileSystem-Providerspecific to the FileSystem providerspecific to the FileSystem providerNeeds-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management modulecmdlets in the Microsoft.PowerShell.Management module