Precheck Job to Check for Files

Follow

This precheck job can be used to check for the presence of files in a directory.  The precheck job will error if the files are not there, and will succeed if any files are there. 

This script uses Test-Path, which returns a Boolean value depending on the result.  

Microsoft documentation on the usage of Test-Path can be found here:

Using Test-Path to Verify the Existence of an Object

### Do our files exist?  We are looking for any files with .zip extenstion, this can be customized for any files
$file = Test-Path c:\Temp\*.zip

### If Files exist we exit to success, if not, we throw an error which will appear in JAMS.
if($file -eq $true){

Write-Host "The files exist! Precheck Success!"

$Host.SetShouldExit(0)

}
Else{

Throw "Zip Files are not there!"

}
Have more questions? Submit a request

Comments