You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Copy-Item with "-Exclude" or/and "-Include" parameters makes it succeed for non-existing source paths #4988
Area-FileSystem-Providerspecific to the FileSystem providerIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdletsgeneral cmdlet issuesWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
Assuming "a" and "b" refer to non-existing filesystem items (CWD is "C:", Windows system NTFS partition), executing Copy-Item a b produces, as expected, an error where Powershell can't find "a":
Copy-Item : Cannot find path 'C:\a' because it does not exist.
Adding the -Exclude c parameter like Copy-Item a b -Exclude c makes, however, the otherwise identical command succeed without errors (checked success with echo $? which returns True). Whether c is an existing item or not is inconsequential here.
I would say this behavior is very unexpected. I expect the second command to fail because source does not exist, irrespective of which paths under the source were to be excluded during copying.
Can anyone comment on this? Am I missing something?
Output of echo $PSVersionTable:
PSVersion 5.0.10586.117
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.10586.117
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Windows 7 x86_64 (6.1.7601 Service Pack 1 Build 7601).
changed the title [-]Copy-Item with "-Exclude" parameter makes it succeed for non-existing source paths[/-][+]Copy-Item with "-Exclude" or/and "-Include" parameters makes it succeed for non-existing source paths[/+]on Oct 4, 2017
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commented on Nov 23, 2023
Area-FileSystem-Providerspecific to the FileSystem providerIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreWG-Cmdletsgeneral cmdlet issuesWG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.
Activity
[-]Copy-Item with "-Exclude" parameter makes it succeed for non-existing source paths[/-][+]Copy-Item with "-Exclude" or/and "-Include" parameters makes it succeed for non-existing source paths[/+]iSazonov commentedon Oct 4, 2017
Armen Michaeli (@amn) Thanks for your report!
I can repo on PowerShell Core 6.0 Beta.7. For -Include too.
Michael Klement (@mklement0) Could you please comment?
mklement0 commentedon Oct 4, 2017
I see the issue too (in PS Core) and it smells like a bug to me as well.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 16, 2023
This issue has not had any activity in 6 months, if this is a bug please try to reproduce on the latest version of PowerShell and reopen a new issue and reference this issue if this is still a blocker for you.
microsoft-github-policy-service commentedon Nov 23, 2023
This issue has been marked as "No Activity" as there has been no activity for 6 months. It has been closed for housekeeping purposes.