Adam McGurk
Adam McGurk

Reputation: 476

Remove-Item not working in Windows Temp folder

I have a server with an incredibly overloaded Windows/Temp folder. So, I wanted to run a simple Powershell script to clear it out (I'm talking tens of thousands of .tmp and .bak files that are over a year old). Below is the code:

Remove-Item C:\Windows\Temp\* -Include .txt,.bak,.tmp -WhatIf

I tried removing the -WhatIf as well (I just had that in there because I was playing around with some stuff) and nothing happens. It's so simple I'm almost definitely missing something simple.

Upvotes: 1

Views: 580

Answers (1)

user2465173
user2465173

Reputation: 36

Missing wildcard on the -include:

Remove-Item C:\Windows\Temp\* -Include *.txt, *.bak, *.tmp -WhatIf

Upvotes: 2

Related Questions