René's URL Explorer Experiment


Title: Inconsistencies between Get-ChildItem and Remove-Item with respect to -Recurse and -Include · Issue #3727 · PowerShell/PowerShell · GitHub

Open Graph Title: Inconsistencies between Get-ChildItem and Remove-Item with respect to -Recurse and -Include · Issue #3727 · PowerShell/PowerShell

X Title: Inconsistencies between Get-ChildItem and Remove-Item with respect to -Recurse and -Include · Issue #3727 · PowerShell/PowerShell

Description: Update: Based on Andrew Stanton (@StingyJack)'s feedback, part of this issue may be related to a longstanding known Remove-Item problem currently documented as: When it is used with the Include parameter, the Recurse parameter might not ...

Open Graph Description: Update: Based on Andrew Stanton (@StingyJack)'s feedback, part of this issue may be related to a longstanding known Remove-Item problem currently documented as: When it is used with the Include par...

X Description: Update: Based on Andrew Stanton (@StingyJack)'s feedback, part of this issue may be related to a longstanding known Remove-Item problem currently documented as: When it is used with the Include...

Opengraph URL: https://github.com/PowerShell/PowerShell/issues/3727

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Inconsistencies between Get-ChildItem and Remove-Item with respect to -Recurse and -Include","articleBody":"_Update_: Based on @StingyJack's feedback, part of this issue may be related to a longstanding _known `Remove-Item` problem_ [currently documented as](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/remove-item?view=powershell-6):\r\n\r\n> When it is used with the `Include` parameter, the `Recurse` parameter might not delete all subfolders or all child items. This is a known issue. \r\n\r\n---\r\n\r\n`Get-ChildItem` allows the following idioms to look for matching files on _all_ levels of the target directory's hierarchy:\r\n\r\n```powershell\r\nGet-ChildItem *.txt -Recurse\r\nGet-ChildItem .  -Recurse -Include *.txt\r\n```\r\n\r\nBy contrast, these idioms currently do _not_ work with `Remove-Item`:\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\n```powershell\r\nSet-Location ~\r\n\r\nGet-ChildItem *.txt -Recurse\r\nGet-ChildItem . -Recurse -Include *.txt\r\n\r\nRemove-Item *.txt -Recurse -WhatIf\r\nRemove-Item . -Recurse -Include *.txt -WhatIf\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\nAll 4 commands should output / target the same set of files, across the directory hierarchy.\r\n\r\nActual behavior\r\n---------------\r\n\r\nThe `Get-ChildItem` commands behave as expected.\r\n\r\nThe `Remove-Item` commands do not:\r\n\r\n* `Remove-Item *.txt -Recurse -WhatIf` only targets items _directly_ in the target directory (does not recurse) \r\n    * This behavior is sensible, but it deviates from `Get-ChildItem`'s behavior - see #5699\r\n\r\n* `Remove-Item . -Recurse -Include *.txt -WhatIf` fails.  \r\nE.g., on macOS: `Remove-Item : Cannot remove the item at '/Users/jdoe' because it is in use.`; i.e., an attempt is made to blindly remove `.`, without considering the `-Include` wildcard pattern.\r\n\r\n  * Note that the problem does _not_ occur if you target a directory by _name or path_, from a _different_ directory (rather than with `.` from _inside_ it).\r\n\r\nEnvironment data\r\n----------------\r\n\r\n\r\n```powershell\r\nPowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on macOS 10.12.4\r\nPowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on Microsoft Windows 10 Pro (64-bit; v10.0.14393)\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2017-05-07T21:16:48Z","url":"https://github.com/PowerShell/PowerShell/issues/3727"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:ad3862a2-6d99-6966-7ec4-1e6d40f2b611
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE876:25FFAF:B23B42:FE4FDD:6AFDA632
html-safe-noncea43a7c92812d2b59981fc95e09bf3a29cc0ac0cea1743c18d0422be884778ab0
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFODc2OjI1RkZBRjpCMjNCNDI6RkU0RkREOjZBRkRBNjMyIiwidmlzaXRvcl9pZCI6Ijg3OTkzODUxMDM1NTA0OTAxNjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac54e5f11c3c47d2bb23abf76b848dd89d2ea471e818b18da0d14e41bcea1b1192
hovercard-subject-tagissue:226895199
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PowerShell/3727/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3a117c6088e924825acf334a5f67c519966891788825aa1dd1bde47d9a98da1b/PowerShell/PowerShell/issues/3727
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3a117c6088e924825acf334a5f67c519966891788825aa1dd1bde47d9a98da1b/PowerShell/PowerShell/issues/3727
og:image:altUpdate: Based on Andrew Stanton (@StingyJack)'s feedback, part of this issue may be related to a longstanding known Remove-Item problem currently documented as: When it is used with the Include par...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamemklement0
hostnamegithub.com
expected-hostnamegithub.com
Nonebc86424ef34a73b386237872800e922d149d65ba907f63d6f150a2dcb8433bea
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id49609581
octolytics-dimension-repository_nwoPowerShell/PowerShell
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49609581
octolytics-dimension-repository_network_root_nwoPowerShell/PowerShell
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release0ddf53eb35c87f1f8df13dbf75c3bdadbfc6e969
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/PowerShell/PowerShell/issues/3727#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F3727
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPowerShell%2Fissues%2F3727
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPowerShell
Reloadhttps://github.com/PowerShell/PowerShell/issues/3727
Reloadhttps://github.com/PowerShell/PowerShell/issues/3727
Reloadhttps://github.com/PowerShell/PowerShell/issues/3727
PowerShellhttps://github.com/PowerShell
PowerShellhttps://github.com/PowerShell/PowerShell
Codehttps://github.com/PowerShell/PowerShell
Issues1.3k (1.3k)https://github.com/PowerShell/PowerShell/issues
Pull requests366 (366)https://github.com/PowerShell/PowerShell/pulls
Discussionshttps://github.com/PowerShell/PowerShell/discussions
Actionshttps://github.com/PowerShell/PowerShell/actions
Projectshttps://github.com/PowerShell/PowerShell/projects
Security and quality3 (3)https://github.com/PowerShell/PowerShell/security
Insightshttps://github.com/PowerShell/PowerShell/insights
https://github.com/PowerShell/PowerShell
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/3727
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/3727
Inconsistencies between Get-ChildItem and Remove-Item with respect to -Recurse and -Includehttps://github.com/PowerShell/PowerShell/issues/3727#top
Area-FileSystem-Providerspecific to the FileSystem providerhttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Area-FileSystem-Provider%22
Issue-BugIssue has been identified as a bug in the producthttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Bug%22
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
WG-Cmdletsgeneral cmdlet issueshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Cmdlets%22
WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Engine-Providers%22
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on May 7, 2017https://github.com/PowerShell/PowerShell/issues/3727#issue-226895199
Andrew Stanton (@StingyJack)https://github.com/StingyJack
currently documented ashttps://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/remove-item?view=powershell-6
Get-ChildItem -Recurse treats literals passed to -Path like wildcard expressions #5699https://github.com/PowerShell/PowerShell/issues/5699
Ilya (iSazonov)https://github.com/iSazonov
Area-Cmdlets-Managementhttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Area-Cmdlets-Management%22
Issue-BugIssue has been identified as a bug in the producthttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Bug%22
on May 8, 2017https://github.com/PowerShell/PowerShell/issues/3727#event-1072231294
https://github.com/StingyJack
Andrew Stanton (StingyJack)https://github.com/StingyJack
on Feb 8, 2018https://github.com/PowerShell/PowerShell/issues/3727#issuecomment-364137513
Michael Klement (mklement0)https://github.com/mklement0
on Nov 8, 2018https://github.com/PowerShell/PowerShell/issues/3727#event-1954383022
https://github.com/mickaeltr
Mickaël Tricot (mickaeltr)https://github.com/mickaeltr
on May 13, 2020https://github.com/PowerShell/PowerShell/issues/3727#issuecomment-627826589
Andrew Stanton (@StingyJack)https://github.com/StingyJack
https://www.youtube.com/watch?v=uhRWMGBjlO8&feature=youtu.be&t=455https://www.youtube.com/watch?v=uhRWMGBjlO8&feature=youtu.be&t=455
https://stackoverflow.com/questions/53553729/cannot-remove-item-the-directory-is-not-empty/53561052#53561052https://stackoverflow.com/questions/53553729/cannot-remove-item-the-directory-is-not-empty/53561052#53561052
https://camo.githubusercontent.com/aeb19ac101480369de19891df079dcdc760086ebe52cb08bd98183bfd18396e9/68747470733a2f2f63646e2e737374617469632e6e65742f53697465732f737461636b6f766572666c6f772f496d672f6170706c652d746f7563682d69636f6e40322e706e673f763d373364373961383962646564
Cannot remove item, The Directory is not emptyhttps://stackoverflow.com/questions/53553729/cannot-remove-item-the-directory-is-not-empty
https://github.com/mklement0
Michael Klement (mklement0)https://github.com/mklement0
on May 13, 2020https://github.com/PowerShell/PowerShell/issues/3727#issuecomment-627990319
Mickaël Tricot (@mickaeltr)https://github.com/mickaeltr
#8211https://github.com/PowerShell/PowerShell/issues/8211
https://github.com/mickaeltr
Mickaël Tricot (mickaeltr)https://github.com/mickaeltr
on May 13, 2020https://github.com/PowerShell/PowerShell/issues/3727#issuecomment-627999750
Michael Klement (@mklement0)https://github.com/mklement0
Ilya (iSazonov)https://github.com/iSazonov
Area-FileSystem-Providerspecific to the FileSystem providerhttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Area-FileSystem-Provider%22
WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Engine-Providers%22
on Nov 29, 2021https://github.com/PowerShell/PowerShell/issues/3727#event-5686694969
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 16, 2023https://github.com/PowerShell/PowerShell/issues/3727#issuecomment-1814125670
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 16, 2023https://github.com/PowerShell/PowerShell/issues/3727#issuecomment-1814125678
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
on Nov 16, 2023https://github.com/PowerShell/PowerShell/issues/3727#event-10978409271
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 16, 2023https://github.com/PowerShell/PowerShell/issues/3727#issuecomment-1814134495
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
https://github.com/apps/microsoft-github-policy-service
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
on Nov 23, 2023https://github.com/PowerShell/PowerShell/issues/3727#issuecomment-1824500279
Microsoft GitHub Policy Servicehttps://aka.ms/1es-gitops
microsoft-github-policy-servicehttps://github.com/apps/microsoft-github-policy-service
completedhttps://github.com/PowerShell/PowerShell/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on Nov 23, 2023https://github.com/PowerShell/PowerShell/issues/3727#event-11048171227
Ryan Yates (kilasuit)https://github.com/kilasuit
WG-Cmdletsgeneral cmdlet issueshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Cmdlets%22
WG-Cmdlets-Managementhttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Cmdlets-Management%22
on Jul 18, 2026https://github.com/PowerShell/PowerShell/issues/3727#event-28146814820
Sign up for freehttps://github.com/signup?return_to=https://github.com/PowerShell/PowerShell/issues/3727
Sign in to commenthttps://github.com/login?return_to=https://github.com/PowerShell/PowerShell/issues/3727
Area-FileSystem-Providerspecific to the FileSystem providerhttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Area-FileSystem-Provider%22
Issue-BugIssue has been identified as a bug in the producthttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Issue-Bug%22
Resolution-No ActivityIssue has had no activity for 6 months or morehttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22Resolution-No%20Activity%22
WG-Cmdletsgeneral cmdlet issueshttps://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Cmdlets%22
WG-Engine-Providersbuilt-in PowerShell providers such as FileSystem, Certificates, Registry, etc.https://github.com/PowerShell/PowerShell/issues?q=state%3Aopen%20label%3A%22WG-Engine-Providers%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.