Delete all temp folders contents

Execute the script to delete all temp folder contents.

Script

<#
.SYNOPSIS
This script can be used to delete all temp files.
.DESCRIPTION
This script can be used to delete all temp files.
.EXAMPLE
C:\PS> C:\Script\Temp_Files_Delete.ps1
Deletes all temp files in the system.
#>
#Fetches all temp folders and deletes files in it recursively.

$tempfolders = @(“C:\Windows\Temp\*”, “C:\Windows\Prefetch\*”, “C:\Documents and Settings\*\Local Settings\temp\*”, “C:\Users\*\Appdata\Local\Temp\*”)
Remove-Item $tempfolders -force -recurse

 

Output
Temp

Leave a Reply