1

There is no output to this script when I run it. I think that its something obvious but although it creates the test.txt, no data is put in it on files that it deletes!

Thanks in advance

$limit = (Get-Date).AddDays(-7) 
Get-ChildItem 'C:\temp' -Recurse | 
Where-Object {
 -not $_.PSIsContainer -and $_.CreationTime -lt $limit 
} |  Remove-Item | Out-File -FilePath c:\text.txt

1 Answer 1

4

Remove-Item has no output. You can enable verbose output from Remove-Item and then redirect the Verbose stream to the standard output stream like so:

... | Remove-Item -Verbose 4>&1 > c:\text.txt
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.