I am running a powershell script from the post-job command. It calls powershell.exe and then uses -file and -noninteractive to run the script. The script calls get-bejobhistory on the currently running job to get it's completion status. The script runs on the media server, and is supposed to run after the verify, which is a separate job. The purpose is to re-run the job up to three times, then fail out. To get started I am just get the history of the job and saving it to a .CSV file. The problem is after the job runs regardless of status, I have a blank file, 0 bytes. When I run it from powershell it works perfectly. Obviusly when I run the script the job is not running.
Is there a way to get this working?
Here is the very simple script:
$LastRun = Get-BEJobHistory -name "BAUERDB2 VIRTUAL SERVER BACKUP-differential" -FromStartTime $(get-date -uformat "%m/%d/%y") -FromLastJobRun
$LastRun | export-csv -path C:\Users\public\Documents\BAUERDB2-Diff.csv -notypeinformation