-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fixes #12621 - Document behavior of wildcard matching when -Destination doesn't exist #12670
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -114,6 +114,10 @@ Copy-Item -Path "C:\Logfiles" -Destination "C:\Drawings\Logs" -Recurse | |||||||||||||||||
| > trees, are copied to the new destination directory. For example: | ||||||||||||||||||
| > | ||||||||||||||||||
| > `Copy-Item -Path "C:\Logfiles\*" -Destination "C:\Drawings\Logs" -Recurse` | ||||||||||||||||||
| > | ||||||||||||||||||
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | ||||||||||||||||||
| > exist, all files in `C:\Logfiles` are copied to `C:\Drawings\Logs` as a file. The `C:\Drawings` | ||||||||||||||||||
| > file is a copy of the last file in the `C:\Logfiles` directory. | ||||||||||||||||||
|
Comment on lines
+118
to
+120
|
||||||||||||||||||
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | |
| > exist, all files in `C:\Logfiles` are copied to `C:\Drawings\Logs` as a file. The `C:\Drawings` | |
| > file is a copy of the last file in the `C:\Logfiles` directory. | |
| > If `C:\Logfiles` contains only files (no subdirectories) and `C:\Drawings\Logs` doesn't exist, | |
| > each file in `C:\Logfiles` is copied in turn to the same destination path, `C:\Drawings\Logs`, | |
| > so each copy overwrites the previous one. The resulting `C:\Drawings\Logs` file is a copy of | |
| > the last file in the `C:\Logfiles` directory. |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent reference: The sentence refers to "The C:\Drawings file" but previously mentions "C:\Drawings\Logs" as the destination. This creates confusion because C:\Drawings is described as a file rather than a directory. The sentence should clarify that when C:\Drawings\Logs doesn't exist, it's treated as a file path (not a directory), and explain the behavior more clearly.
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | |
| > exist, all files in `C:\Logfiles` are copied to `C:\Drawings\Logs` as a file. The `C:\Drawings` | |
| > file is a copy of the last file in the `C:\Logfiles` directory. | |
| > If `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | |
| > exist, the destination path is treated as a file name rather than a directory. A single file | |
| > named `C:\Drawings\Logs` is created, and its contents are a copy of the last file in the | |
| > `C:\Logfiles` directory that is processed. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |||||||||||||||||
| external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml | ||||||||||||||||||
| Locale: en-US | ||||||||||||||||||
| Module Name: Microsoft.PowerShell.Management | ||||||||||||||||||
| ms.date: 11/04/2024 | ||||||||||||||||||
| ms.date: 01/17/2026 | ||||||||||||||||||
| online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/copy-item?view=powershell-7.4&WT.mc_id=ps-gethelp | ||||||||||||||||||
| schema: 2.0.0 | ||||||||||||||||||
| aliases: | ||||||||||||||||||
|
|
@@ -113,6 +113,10 @@ Copy-Item -Path "C:\Logfiles" -Destination "C:\Drawings\Logs" -Recurse | |||||||||||||||||
| > trees, are copied to the new destination directory. For example: | ||||||||||||||||||
| > | ||||||||||||||||||
| > `Copy-Item -Path "C:\Logfiles\*" -Destination "C:\Drawings\Logs" -Recurse` | ||||||||||||||||||
| > | ||||||||||||||||||
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | ||||||||||||||||||
|
||||||||||||||||||
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | |
| > If `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent reference: The sentence refers to "The C:\Drawings file" but previously mentions "C:\Drawings\Logs" as the destination. This creates confusion because C:\Drawings is described as a file rather than a directory. The sentence should clarify that when C:\Drawings\Logs doesn't exist, it's treated as a file path (not a directory), and explain the behavior more clearly.
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | |
| > exist, all files in `C:\Logfiles` are copied to `C:\Drawings\Logs` as a file. The `C:\Drawings` | |
| > file is a copy of the last file in the `C:\Logfiles` directory. | |
| > If `C:\Logfiles` contains only files and no subdirectories and `C:\Drawings\Logs` doesn't exist, | |
| > `Copy-Item` treats `C:\Drawings\Logs` as the full path to a file, not a directory. All files in | |
| > `C:\Logfiles` are copied in sequence, and the contents of the last file overwrite the previous | |
| > content. The resulting `C:\Drawings\Logs` file contains the contents of the last file in the | |
| > `C:\Logfiles` directory. |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation states "all files in C:\Logfiles are copied to C:\Drawings\Logs as a file" which is confusing and unclear. The phrase "copied to C:\Drawings\Logs as a file" doesn't make sense because multiple files cannot be copied to a single file path. The statement should clarify that each file except the last is overwritten by the next, resulting in only the last file being preserved, or describe the actual behavior more accurately.
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | |
| > exist, all files in `C:\Logfiles` are copied to `C:\Drawings\Logs` as a file. The `C:\Drawings` | |
| > file is a copy of the last file in the `C:\Logfiles` directory. | |
| > If `C:\Logfiles` contains only files and no subdirectories, and `C:\Drawings\Logs` doesn't | |
| > exist, PowerShell treats `C:\Drawings\Logs` as a file path rather than a directory. Each file in | |
| > `C:\Logfiles` is copied in turn to `C:\Drawings\Logs`, overwriting the previous one, so the final | |
| > `C:\Drawings\Logs` file is a copy of the last file in the `C:\Logfiles` directory. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |||||||||||||||||
| external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml | ||||||||||||||||||
| Locale: en-US | ||||||||||||||||||
| Module Name: Microsoft.PowerShell.Management | ||||||||||||||||||
| ms.date: 11/04/2024 | ||||||||||||||||||
| ms.date: 01/17/2026 | ||||||||||||||||||
| online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/copy-item?view=powershell-7.5&WT.mc_id=ps-gethelp | ||||||||||||||||||
| schema: 2.0.0 | ||||||||||||||||||
| aliases: | ||||||||||||||||||
|
|
@@ -113,6 +113,10 @@ Copy-Item -Path "C:\Logfiles" -Destination "C:\Drawings\Logs" -Recurse | |||||||||||||||||
| > trees, are copied to the new destination directory. For example: | ||||||||||||||||||
| > | ||||||||||||||||||
| > `Copy-Item -Path "C:\Logfiles\*" -Destination "C:\Drawings\Logs" -Recurse` | ||||||||||||||||||
| > | ||||||||||||||||||
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | ||||||||||||||||||
|
||||||||||||||||||
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | |
| > If `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation states "all files in C:\Logfiles are copied to C:\Drawings\Logs as a file" which is confusing and unclear. The phrase "copied to C:\Drawings\Logs as a file" doesn't make sense because multiple files cannot be copied to a single file path. The statement should clarify that each file except the last is overwritten by the next, resulting in only the last file being preserved, or describe the actual behavior more accurately.
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | |
| > exist, all files in `C:\Logfiles` are copied to `C:\Drawings\Logs` as a file. The `C:\Drawings` | |
| > file is a copy of the last file in the `C:\Logfiles` directory. | |
| > If `C:\Logfiles` contains only files (no subdirectories) and `C:\Drawings\Logs` doesn't | |
| > exist, each file in `C:\Logfiles` is copied in turn to the same destination path, | |
| > `C:\Drawings\Logs`. Each copy operation overwrites the previous one, so the resulting | |
| > `C:\Drawings\Logs` file contains the contents of only the last file in the `C:\Logfiles` | |
| > directory. |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent reference: The sentence refers to "The C:\Drawings file" but previously mentions "C:\Drawings\Logs" as the destination. This creates confusion because C:\Drawings is described as a file rather than a directory. The sentence should clarify that when C:\Drawings\Logs doesn't exist, it's treated as a file path (not a directory), and explain the behavior more clearly.
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | |
| > exist, all files in `C:\Logfiles` are copied to `C:\Drawings\Logs` as a file. The `C:\Drawings` | |
| > file is a copy of the last file in the `C:\Logfiles` directory. | |
| > If `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | |
| > exist, `Copy-Item` treats `C:\Drawings\Logs` as a file path, not a directory. Each file from | |
| > `C:\Logfiles` is copied in turn to `C:\Drawings\Logs`, so the `C:\Drawings\Logs` file ends up | |
| > containing the contents of the last file in the `C:\Logfiles` directory. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |||||||||||||||
| external help file: Microsoft.PowerShell.Commands.Management.dll-Help.xml | ||||||||||||||||
| Locale: en-US | ||||||||||||||||
| Module Name: Microsoft.PowerShell.Management | ||||||||||||||||
| ms.date: 11/04/2024 | ||||||||||||||||
| ms.date: 01/17/2026 | ||||||||||||||||
| online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.management/copy-item?view=powershell-7.6&WT.mc_id=ps-gethelp | ||||||||||||||||
| schema: 2.0.0 | ||||||||||||||||
| aliases: | ||||||||||||||||
|
|
@@ -113,6 +113,10 @@ Copy-Item -Path "C:\Logfiles" -Destination "C:\Drawings\Logs" -Recurse | |||||||||||||||
| > trees, are copied to the new destination directory. For example: | ||||||||||||||||
| > | ||||||||||||||||
| > `Copy-Item -Path "C:\Logfiles\*" -Destination "C:\Drawings\Logs" -Recurse` | ||||||||||||||||
| > | ||||||||||||||||
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | ||||||||||||||||
|
||||||||||||||||
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | |
| > If `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation states "all files in C:\Logfiles are copied to C:\Drawings\Logs as a file" which is confusing and unclear. The phrase "copied to C:\Drawings\Logs as a file" doesn't make sense because multiple files cannot be copied to a single file path. The statement should clarify that each file except the last is overwritten by the next, resulting in only the last file being preserved, or describe the actual behavior more accurately.
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | |
| > exist, all files in `C:\Logfiles` are copied to `C:\Drawings\Logs` as a file. The `C:\Drawings` | |
| > If `C:\Logfiles` contains only files (no subdirectories) and `C:\Drawings\Logs` doesn't | |
| > exist, PowerShell treats `C:\Drawings\Logs` as the path to a single file. Each file from | |
| > `C:\Logfiles` is copied to that same destination path in turn, so the final `C:\Drawings\Logs` |
Copilot
AI
Jan 17, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent reference: The sentence refers to "The C:\Drawings file" but previously mentions "C:\Drawings\Logs" as the destination. This creates confusion because C:\Drawings is described as a file rather than a directory. The sentence should clarify that when C:\Drawings\Logs doesn't exist, it's treated as a file path (not a directory), and explain the behavior more clearly.
| > If the `C:\Logfiles` only contains files and no subdirectories and `C:\Drawings\Logs` doesn't | |
| > exist, all files in `C:\Logfiles` are copied to `C:\Drawings\Logs` as a file. The `C:\Drawings` | |
| > file is a copy of the last file in the `C:\Logfiles` directory. | |
| > If `C:\Logfiles` contains only files and no subdirectories and `C:\Drawings\Logs` doesn't | |
| > exist, PowerShell treats `C:\Drawings\Logs` as the path of a single file in the `C:\Drawings` | |
| > directory. All files in `C:\Logfiles` are copied, but the resulting `C:\Drawings\Logs` file | |
| > contains the contents of the last file copied from the `C:\Logfiles` directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammar error: "If the C:\Logfiles only contains" should be "If C:\Logfiles only contains" (remove "the" before the path). Paths used as subjects don't require the article "the" in this context.