Create my own Job

In order to get started either open any powershell IDE or open the powerJobs Processor ISE shortcut in the start menu, which already opens one of our sample scripts for you.
Import the Module by calling Import-Module powerJobs.

Our standard delivery comes with a couple of sample scripts located in %ALLUSERSPROFILE%\coolOrange\powerJobs\Jobs that can be used as templates for new jobs.

Before you can work you have to connect to Vault using the Open-VaultConnection Commandlet.

After successful connection, you can start to work with powerJobs Processor.
Lets search for a random drawing file:

$file = Get-VaultFile -Properties @{'File Extension'='idw'} #Search for a Drawing file

In your IDE create a new script file with a meaningful name and place it in the Jobs directory.
In this example we are going to download the file, open it in the Inventor application and export it as PDF.

Download the file from Vault

We will use the Save-Vaultfile Commandlet to download the file to our working directory.

$workingDirectory = "C:\Temp\$($file._Name)"
$downloadedFiles = Save-VaultFile -File $file.'Full Path' -DownloadDirectory $workingDirectory

Open the file in Inventor

After downloading the file to the working directory we will use the Open-Document Commandlet to open the file in Inventor.

$file = $downloadedFiles | select -First 1
Open-Document -LocalFile $file.LocalPath -Application 'Inventor'

Exporting the file

Now we can export the document as PDF, using the Export-Document Commandlet.

$localPDFfileLocation = "C:\Temp\$($file._Name).pdf"
Export-Document -Format 'PDF' -To $localPDFfileLocation

Closing the opened file

Finally we close the file and clean up the working directory, using the Close-Document and Clean-Up Commandlet.

Clean-Up -folder $workingDirectory

When an exception is thrown within a Job script, the according job is marked with the Failure status in the Job Queue.

In your job script you should use the powershell's throw keyword in order to raise exceptions manually and you can handle them by using try/catch blocks:

    $files = $vaultConnection.FileManager.AcquireFiles($settings)
    throw("Failed to aquire files")
By default the script execution will terminate, because the variable $ErrorActionPreference is set to 'Stop'.
In order to change the PowerShell error handling behavior for all jobs globally, you can change this varible in the Setup_Job.ps1 script.

The exception messages can be found directly in the Result of the failed jobs.

Additionally more detailed information are written directly to the Trace Window and to the logfile and can be configured within the according Logging sections.