Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy-Item -Include -Recurse needs clarification and examples #8601

Closed
3 tasks done
SteveL-MSFT opened this issue Feb 20, 2022 · 1 comment · Fixed by #8734
Closed
3 tasks done

Copy-Item -Include -Recurse needs clarification and examples #8601

SteveL-MSFT opened this issue Feb 20, 2022 · 1 comment · Fixed by #8734
Labels
area-management Area - Microsoft.PowerShell.Management module issue-doc-bug Issue - error in documentation needs-more-info Waiting - for more information

Comments

@SteveL-MSFT
Copy link
Contributor

Prerequisites

  • Write a descriptive title.
  • Search the existing issues.
  • I am reporting the documentation problem for version of PowerShell I am using.

Version

5.1, 7.0, 7.1, 7.2, 7.3 (preview)

Link to affected document

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/copy-item?view=powershell-7.2

Description of the documentation error

The -Include parameter of Copy-Item says: "The value of this parameter qualifies the Path parameter." This is not clear to the user where they expect -Include to filter the results, but instead is a filter on the -Path globbing. As discussed in this issue by the Cmdlets WG PowerShell/PowerShell#16219, we believe more clarification is needed as well as some specific examples showing that -Include filters against -Path (while Copy-item does what users expect which is -Include filters on the results).

Suggested fix

Change "The value of this parameter qualifies the Path parameter." to "The value of this parameter qualifies the Path parameter. This means that -Include filters against the globbing (wildcard matching) result of -Path and not against the final results. This may be unexpected behavior when used with -Recurse as it only filters against the top level results and not the recursive results."

Add examples showing that -Path example* -Include *.txt -Recurse would only match example*.txt and not files within the example* folders that end in .txt.

@SteveL-MSFT SteveL-MSFT added issue-doc-bug Issue - error in documentation needs-triage Waiting - Needs triage labels Feb 20, 2022
@sdwheeler sdwheeler added area-management Area - Microsoft.PowerShell.Management module review-shiproom Waiting - for Shiproom discussion and removed needs-triage Waiting - Needs triage labels Feb 22, 2022
@sdwheeler
Copy link
Contributor

@SteveL-MSFT There are 37 cmdlets that have -include and -exclude. Does this behavior apply to all of these cmdlets? What about the behavior of -exclude?

@sdwheeler sdwheeler added needs-more-info Waiting - for more information and removed review-shiproom Waiting - for Shiproom discussion labels Mar 9, 2022
michaeltlombardi added a commit to michaeltlombardi/PowerShell-Docs that referenced this issue Apr 13, 2022
Prior to this commit, the documentation for the Include parameter of the
Copy-Item cmdlet was unclear. This commit clarifies its functionality
and adds a new example to show how it is used and where its behavior
might be otherwise surprising.
michaeltlombardi added a commit to michaeltlombardi/PowerShell-Docs that referenced this issue Apr 13, 2022
Prior to this commit, the documentation for the Include parameter of the
Copy-Item cmdlet was unclear. This commit clarifies its functionality
and adds a new example to show how it is used and where its behavior
might be otherwise surprising.
sdwheeler added a commit that referenced this issue Apr 14, 2022
* (GH-8601) Clarify Include parameter for Copy-Item

Prior to this commit, the documentation for the Include parameter of the
Copy-Item cmdlet was unclear. This commit clarifies its functionality
and adds a new example to show how it is used and where its behavior
might be otherwise surprising.

* Apply suggestions from code review

* Added recurse example

Co-authored-by: Sean Wheeler <sean.wheeler@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-management Area - Microsoft.PowerShell.Management module issue-doc-bug Issue - error in documentation needs-more-info Waiting - for more information
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants