Windows / Sharepoint / User Temp files Auto deletion PowerShell Script
+++++++++++++++++++++++++++++++++++++++++
$tempfolders = @("C:\Windows\Temp\*", "C:\Users\*\Appdata\Local\Temp\*", "C:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp\*", "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\PETGeneral\DMSTemp\*" ,"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\PETV2\DMSTemp\*")
Remove-Item $tempfolders -force -recurse
+++++++++++++++++++++++++++++++++++++++++
Copy above text in PS1 file. e.g. TempFileDeletion.ps1
Schedule it with Windows Task Scheduler :
Run the below command in PowerShell for changing Execution Policy.
Its Done.
+++++++++++++++++++++++++++++++++++++++++
$tempfolders = @("C:\Windows\Temp\*", "C:\Users\*\Appdata\Local\Temp\*", "C:\Windows\ServiceProfiles\LocalService\AppData\Local\Temp\*", "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\PETGeneral\DMSTemp\*" ,"C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\PETV2\DMSTemp\*")
Remove-Item $tempfolders -force -recurse
+++++++++++++++++++++++++++++++++++++++++
Copy above text in PS1 file. e.g. TempFileDeletion.ps1
Schedule it with Windows Task Scheduler :
Run the below command in PowerShell for changing Execution Policy.
Its Done.