Thursday, October 1, 2015

Windows / Sharepoint / User Temp files Auto deletion PowerShell Script

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.

1 comment:

  1. It’s really a great to see the post like this which provides a meaningful data to someone who is new to this field, thanks for sharing it.

    Reach out to your customers within a short period of time anywhere and anytime in the world with email marketing, b2b marketing, list solutions.

    Health Care CEO email Lists
    Hospital CEO email Lists
    Insurance companies CEO Email Lists
    International CEO Email Lists
    Pharmaceutical Industry CEO Email Lists
    Automobile Industry CEO Email List
    Software Companies CEO email list
    BPO CEO Email List

    InformationTechnology Mailing & Email Lists

    ReplyDelete

Solved : The user profile failed to attach. The process cannot access the file becase it is being used by another process

Issue :  The user profile failed to attach. Please contact Support. Status : 0x0000000B, Message: Cannot open virtual disk Error Code: 0x000...