Run the DeleteFiles Powershell Script
5.8.0+
Overview
The DeleteFiles Powershell script is a utility script which lives in the Astun\Tools\Powershell directory which can be used through a Workflow Task to clear out directories that can fill up with temporary files over time. This script may also be run from the Command Line.
From the Command Line
.\DeleteFiles -path pathToDirectory -filespec fileTypeToDelete [-age ageToDelete] [-recurse searchChildDirectories] [-ignore listOfFilesToIgnore] [-commit performDeletions]
From Workflow
Create a Program Workflow Task
Name
Enter a unique name for your task. It is advisable to call this something relevant as this name will be used to populate list box selections when creating Jobs e.g. Delete Temporary SLD Files.
Program
Use the browse button to select the powershell.exe program from the Windows folder e.g. c:\windows\syswow64\windowspowershell\v1.0\powershell.exe
Additional Parameters
Here you need to enter the following details:
-ExecutionPolicy Bypass d:\astun\Tools\Powershell\DeleteFiles.ps1 -path d:\astun\isharemap\webservice\sld\ -filespec *.xml -age 1 -commit $true
E.g.
DeleteFile Parameters
Parameter | Description | Example | |
---|---|---|---|
-path | Mandatory | The fully qualified path to the directory that you want to clear. | -path d:\astun\isharemap\webservice\sld\ |
-filespec | Mandatory | The wildcard specifying the type of file you want deleted. | -filespec *.xml |
-age | Defaults to 24 | Delete files over this many hours old, 0 will delete all files. | -age 1 |
-recurse | Defaults to $false | Also delete files from all child directories. | -recurse $true |
-ignore | Defaults to "" | Comma-separated list of files to ignore. | -ignore "test.xml,donotdelete.xml" |
-commit | Defaults to $false | Only deletes any files if this is set to $true, which is useful for testing. | -commit $true |