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
Feature Request: Add parameter to Copy-Item/Move-Item to preserve folder structure #26161
Issue-Enhancementthe issue is more of a feature request than a bugUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtimeWG-ReviewedA Working Group has reviewed this and made a recommendation
As a user, I'd like to be able to recursively copy items that are satisfying a condition other than a name wildcard.
For example, I'd like to recursively copy log files from a folder structure that have been created in the past month to a new folder while keeping the folder structure.
changed the title [-]Feature Request: Add predicate function type to `Copy-Item` to filter items[/-][+]Feature Request: Add predicate script block parameter to `Copy-Item`, `Move-Item`, `Get-ChildItem` for filtering items[/+]on Oct 8, 2025
It would be nice to expand the Filter parameter for the script block. But there are other well-proven and familiar tools, such as filter and *-Object cmdlets
Hi 237dmitry, thank you for this valuable information. Would you mind adding hyperlinks to your comment pointing to some of the Cmdlets you feel are relevant?
The Engine WG discussed this today, the -Filter parameter is meant to be something that can be passed to the provider implementation in order to improve performance in a way that only the implementation is able to. Generally speaking we would also prefer to keep filtering via scriptblock as something done via Where-Object.
That said, we believe the ask of preserving folder structure with Copy-Item/Move-Item is worth pursuing. We would accept a dynamic parameter for the FileSystemProvider surfaced in Copy-Item and Move-Item, that specifies the base path to preserve structure from. This would allow piping objects from Get-ChildItem, filtering, and then passing to the copy/move commands.
# New parameter name undeterminedGet-ChildItem ./logs -File -Recurse
|? LastWriteTime -gt ([System.DateTime]::Today.AddDays(-30))
|Copy-Item-PreservePathFrom ./logs -Destination ./export
changed the title [-]Feature Request: Add predicate script block parameter to `Copy-Item`, `Move-Item`, `Get-ChildItem` for filtering items[/-][+]Feature Request: Add parameter to `Copy-Item`/`Move-Item` to preserve folder structure[/+]on Jul 13, 2026
Issue-Enhancementthe issue is more of a feature request than a bugUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Enginecore PowerShell engine, interpreter, and runtimeWG-ReviewedA Working Group has reviewed this and made a recommendation
Activity
[-]Feature Request: Add predicate function type to `Copy-Item` to filter items[/-][+]Feature Request: Add predicate script block parameter to `Copy-Item`, `Move-Item`, `Get-ChildItem` for filtering items[/+]237dmitry commentedon Oct 8, 2025
It would be nice to expand the Filter parameter for the script block. But there are other well-proven and familiar tools, such as
filterand*-ObjectcmdletsSetTrend commentedon Oct 8, 2025
Hi 237dmitry, thank you for this valuable information. Would you mind adding hyperlinks to your comment pointing to some of the Cmdlets you feel are relevant?
cauamachado51 commentedon Nov 2, 2025
é parecido com o que queria para
Copy-Item: para filtrar-Recurse, algum parâmetro-Only String[]que pode ter:SeeminglyScience commentedon Jul 13, 2026
The Engine WG discussed this today, the
-Filterparameter is meant to be something that can be passed to the provider implementation in order to improve performance in a way that only the implementation is able to. Generally speaking we would also prefer to keep filtering via scriptblock as something done viaWhere-Object.That said, we believe the ask of preserving folder structure with
Copy-Item/Move-Itemis worth pursuing. We would accept a dynamic parameter for theFileSystemProvidersurfaced inCopy-ItemandMove-Item, that specifies the base path to preserve structure from. This would allow piping objects fromGet-ChildItem, filtering, and then passing to the copy/move commands.[-]Feature Request: Add predicate script block parameter to `Copy-Item`, `Move-Item`, `Get-ChildItem` for filtering items[/-][+]Feature Request: Add parameter to `Copy-Item`/`Move-Item` to preserve folder structure[/+]soroshsabz commentedon Nov 20, 2026
ITNOA
@microsoft-github-policy-service In-PR label
/microsoft-github-policy-service add In-PR label
soroshsabz commentedon Nov 20, 2026
Patrick Meinecke (@SeeminglyScience) please add In-PR label