cancel
Showing results for 
Search instead for 
Did you mean: 

Powershell file to run as a post job.

isexpress
Level 2

Hi

 

We have recently upgraded to Symantec Backup Exec 2012 from Backup Exec 2010.

 

We use Veeam to backup to disk and Backup exec to backup to tape.

Our backup strategy is Backup to disk and then to tape. Veeam is used to backup to disk and historically we use the “post job activity” section in veeam to kick of our Veeam files Symantec job to tape.

If I run the bat file manually it runs fine. The bat file is basically a command to run Powershell and run a powershell command to kick of a job in Backup Exec 2012 (which now utilises Windows Powershell rather than traditional command line).

In the Bat file it contains the following:

c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe start-bejob -i '"SymantecBackupjobname"' -confirm:$false

Also in powershell I have imported the module which Symantec uses to run powershell commands. If I run this command manually it works without any issue.

I think a few other Veeam uses also use Backup exec, and I just wanted to know if you had other users who have had this issue.

Any advice would be appreciated.

 

Thanks

2 REPLIES 2

pkh
Moderator
Moderator
   VIP    Certified

Why do you have to put the Powershell commands in a batch file?  You should use Powershell to do everything that you want to do in the batch file and put all the commands including the start-bejob command in a Powershell script.  You then just invoke

Powershell script.ps1

in your post-command.

I do not know how you do you import the BEMCLI module, but this import has to be done for all Powershell sessions which uses BEMCLI cmdlets.  If you just run that command you quoted in a command prompt it would fail unless you have put the import-module command in the appropriate profile.  See my article below

https://www-secure.symantec.com/connect/articles/preparing-your-powershell-environment-run-bemcli-and-scripts

Russell_Norton
Level 3
Employee

First here is a doc for referance

http://www.symantec.com/docs/TECH189795

 

You dont have to use the bat file here is how to run it in-line

cmd.exe /c "powershell.exe -command "& {import-module bemcli;start-bejob <jobname> -confirm:$false}""

using the powershell.exe -command switch allows you to build a script block that imports the module, and execute operations seperated by a ;