Skip to main content

Hi.

 

Does anyone have a strategy for deleting the temporary files in the AppData-folder?

 

We've currently passed 5GB, and the folder was emptied out a little over a year ago.

I'm pretty confident deleting the files doesn't cause any harm, but does anyone have any input on this?

 

Thanks

 

 

 

Ended up creating my own resolution here.

Ran on test-environment first and nothing seems to break.

 

Added the following powershell as a scheduled task. The script deletes all feilas and empty folder older than 150 days in the specified folder.

 

$limit = (Get-Date).AddDays(-150)
$path = "PATH_TO_THE TEMP_FOLDER"

# Delete files older than the $limit.
Get-ChildItem -Path $path -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force

# Delete any empty directories left behind after deleting the old files.
Get-ChildItem -Path $path -Recurse -Force | Where-Object { $_.PSIsContainer -and (Get-ChildItem -Path $_.FullName -Recurse -Force | Where-Object { !$_.PSIsContainer }) -eq $null } | Remove-Item -Force -Recurse

 


Reply