On my 9.0 server (both host and veeam server are 2012r2) I'm attempting to launch pre and post powershell scripts as part of a job. I receive this error for both scripts (they are almost identical):
[16.11.2016 00:55:28] <01> Info Running post-job script
[16.11.2016 00:55:28] <01> Info Executing custom command 'C:\Program Files\Veeam\Backup and Replication\MoveToEH2.ps1', arguments ''
[16.11.2016 00:55:28] <01> Warning Error running post-job: The specified executable is not a valid application for this OS platform.
[16.11.2016 00:55:28] <01> Error The specified executable is not a valid application for this OS platform. (System.ComponentModel.Win32Exception)
I tested a script with the same command on my 9.5 server (both host and veeam server are 2016) and I get this error instead:
[15.11.2016 21:51:29] <01> Info Running pre-job script
[15.11.2016 21:51:29] <01> Info Executing custom command [powershell.exe], arguments ["C:\Program Files\Veeam\Backup and Replication\move.ps1" ]
[15.11.2016 21:51:31] <01> Warning Pre-job script terminated with exit code 1
Any ideas? Spoke with a late-night level 1 tech on the phone and she didn't really seem to have a firm grasp of what powershell is. All we tried was locating the script in different locations on the C drive to no avail. I had tried setting the backup service to run under my enterprise/domain admin account instead of localsystem but also no luck there...
It seems that you're trying to specify a script itself as a pre/post-job activity (such as "Path\Script.ps1"). Thus, the error regarding unsupported type.
Can you try to set the following construction and see whether the issue persists?
When I click "browse" in the area to select the pre and post scripts, the drop down options explicitly list the supported script types. In the dropdown I select Powershell and then it shows me any and all ps1 files in the folder(s) I browse to.
So if it isn't supported to have a powershell script in the field, why would the browse dialog be set up to explicitly encourage choosing and selecting them?
Pushed back on this a little and was contacted by Jeff who was fantastic.
He dug a bit and found that although powershell scripts are selectable directly, there is evidently some kind of bug that prevents them from launching properly.
We were able to get it called via a BAT file after changing the veeam backup service account to my admin user instead of localsystem.
I agree that corresponding masks are bit misleading. The idea has been to provide convenient way to browse files with certain extensions, though, in order to make everything work the reference to application is still required (like, powershell.exe).
We're aware of confusion caused and do plan to fix down the road.
You can also convert your posh scripts to an exe using PS2EXE. Otherwise as others have said you need to call powershell and pass it the path to your script.
I can say for sure that in 9.5 U2 & U3 calling PowerShell scripts directly works fine. I spend 2 weeks testing this.
What I can also say for sure is that sometimes "post" scripts can be tricky since they are being executed as the last part of a job.
So, if the script includes something that involves the job that calls it, it may not work.
That's is both good and bad actually.
The good is that you know if the script ran or not.
The bad is that it does not run "after" the job. e.g. If the job that calls the script is Job1, and I want to run a task after a successful Job1 status that script will never run. The reason as I explained is that the script is part of the job, and hence the success or fail status of the job also depends on, if the script runs or not. So at the time of the script's execution, the job is in progress status.
Ioannis.T wrote:I can say for sure that in 9.5 U2 & U3 calling PowerShell scripts directly works fine. I spend 2 weeks testing this.
What I can also say for sure is that sometimes "post" scripts can be tricky since they are being executed as the last part of a job.
So, if the script includes something that involves the job that calls it, it may not work.
That's is both good and bad actually.
The good is that you know if the script ran or not.
The bad is that it does not run "after" the job. e.g. If the job that calls the script is Job1, and I want to run a task after a successful Job1 status that script will never run. The reason as I explained is that the script is part of the job, and hence the success or fail status of the job also depends on, if the script runs or not. So at the time of the script's execution, the job is in progress status.
I am still trying to find a way around this
Workaround is actually pretty simple, this has been working reliably for me.
Kick off your script using "cmd.exe /C start" which starts it in a new process. Then in your actual script start off with a wait, say 120 seconds to allow Veeam to properly close off the job. After that you can run whatever logic you need which queries the now completed job. I have additional code to check whether there are any pending retries to make sure it only runs when the job is finished.