Site Overlay

Delete Files and Folders with Task Scheduler Delete a File and Folder with PowerShell

image 3

We open the 'Task Scheduler' console by pressing the "Windows + R" keys and typing "taskschd.msc" in the window that opens. We click on "Create Task" and enter a name and description for the new task. We check the box "Run whether user is logged on or not" to run the program with administrator privileges.

Navigate to the "Actions" Tab "New" Action

image 4
C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
Get-ChildItem -Path C:test -Include *.* -Recurse | foreach { $_. Delete()}

Wear and save your commands in the corresponding field.

image 5

Configure the above command according to the directory you will delete according to yourself