Remove the recursion and just search in the main folder:
Get-ChildItem –Path "D:\ABC\Project\*.txt" | Where-Object{$_.CreationTime –lt (Get-Date).AddDays(-15)} | Remove-Item
More Related Contents:
- PowerShell says “execution of scripts is disabled on this system.”
- Create objects with custom properties containing derived filesystem path information and export them to a CSV – calculated properties
- What’s the best way to determine the location of the current PowerShell script?
- Using a Variable (PowerShell) inside of a command
- Changing PowerShell’s default output encoding to UTF-8
- PowerShell outputting array items when interpolating within double quotes
- PSCustomObject to Hashtable
- How can I make PowerShell handle [ or ] in file name well?
- Get remote registry value
- What’s the difference between single quote and double quote to define a string in powershell
- Catching FULL exception message
- Powershell call msbuild with nested quotation marks
- Redirection of standard and error output appending to the same log file
- Convert Unix time with PowerShell
- Replacing only the first occurrence of a word in a string
- How can I get the file system location of a PowerShell script?
- How can I get the current PowerShell executing file?
- What’s the equivalent of xargs in PowerShell?
- You cannot call a method on a null-valued expression
- How do I call the PowerShell CLI robustly, with respect to character encoding, input and output streams, quoting and escaping?
- Visual studio code cmd error: Cannot be loaded because running scripts is disabled on this system
- Invoke-WebRequest, POST with parameters
- Powershell ConvertFrom-Json Encoding Special Characters Issue
- How to use a variable in each loop in Azure DevOps yaml pipeline
- Powershell Formatting for a String
- The response content cannot be parsed because the Internet Explorer engine is not available, or
- PowerShell FTP download files and subfolders
- Powershell: How can I stop errors from being displayed in a script?
- How do I move a file to the Recycle Bin using PowerShell?
- dotnet ef scaffold Unrecognized option ‘-t firstTable -t secondTable’ – pass arguments stored in a string