can't get powershell pre/post scripts to work

PowerShell script exchange

can't get powershell pre/post scripts to work

Veeam Logoby pesos » Wed Nov 16, 2016 5:59 am

support case 01977243

Hi all,

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):
Code: Select all
[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:

Code: Select all
[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...

Thanks!
pesos
Enthusiast
 
Posts: 32
Liked: 1 time
Joined: Wed Nov 12, 2014 9:40 am
Full Name: John Johnson

Re: can't get powershell pre/post scripts to work

Veeam Logoby v.Eremin » Wed Nov 16, 2016 11:32 am

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?

Code: Select all
powershell.exe -file -"Path\Script.ps1"


Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: can't get powershell pre/post scripts to work

Veeam Logoby pesos » Wed Nov 16, 2016 5:29 pm

Hi, I'm a little confused by this reply...

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?
pesos
Enthusiast
 
Posts: 32
Liked: 1 time
Joined: Wed Nov 12, 2014 9:40 am
Full Name: John Johnson

Re: can't get powershell pre/post scripts to work

Veeam Logoby pesos » Wed Nov 16, 2016 6:57 pm

Support has said that the script is launching fine now (from c:\scripts) so it's not their problem.

I find this very poor support since the scripts work perfectly when launched manually on the backup server.

So without more information on exactly how Veeam is launching the script (under what credentials etc) it's very hard to troubleshoot.
pesos
Enthusiast
 
Posts: 32
Liked: 1 time
Joined: Wed Nov 12, 2014 9:40 am
Full Name: John Johnson

Re: can't get powershell pre/post scripts to work

Veeam Logoby pesos » Fri Nov 18, 2016 4:25 am

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.

w00t!
pesos
Enthusiast
 
Posts: 32
Liked: 1 time
Joined: Wed Nov 12, 2014 9:40 am
Full Name: John Johnson

Re: can't get powershell pre/post scripts to work

Veeam Logoby v.Eremin » Fri Nov 18, 2016 10:00 am

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.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: Yahoo [Bot] and 3 guests