Preparing your Powershell environment to run BEMCLI and scripts
Published 13 years ago
Version 1.0Was this article helpful?
Hi PinhoM,
I'm the lead developer for BEMCLI, the PowerShell module for Backup Exec.
What you'll want to do to block your .bat from returning before the job finishes is use "Wait-BEJob".
To get the error code (if any) from the job and return it like a .bat file would, you'll need to get the job history and return its ErrorCode property.
I think this will do the trick for you:
# Note: you can just give the parent directory that contains the module files import-module "c:\program files\symantec\backup exec\modules\bemcli" $job = start-BEJob "In SAO-DB-ORTEMS-D" -Confirm: $ False Wait-BEJob $job $errorCode = $job | Get-BEJobHistory | Select -ExpandProperty ErrorCode return $errorCode # Another way -- you can use a single pipeline for the whole operation like this:
return Start-BEJob "In SAO-DB-ORTEMS-D" -Confirm: $ False | Wait-BEJob | Get-BEJobHistory | Select -ExpandProperty ErrorCode