01-02-2013 04:21 PM
We're in the process of moving from BE2010 to BE2012, and with that I want to monitor the jobs better using theBEMCLI[1] module.
So far, so good, to a degree. Here's what I have:
$serverList = @("server01","server02","server03")
function List-BEJobs {
param(
$serverName
)
$s = New-PSSession -ComputerName $serverName
Invoke-Command -session $s {
Import-Module "C:\Program Files\Symantec\Backup Exec\Modules\BEMCLI\BEMCLI"
Get-BEJob | Get-BEJobHistory -FromLastJobRun -JobType Backup -JobStatus Scheduled
}
Remove-PSSession -session $s
}
$output = ''
foreach ($server in $serverList) {
$BEServer = List-BEJobs -serverName $server | select-object -property *
$BEServer
$output += "Server Name: ",$BEServer.BackupExecServerName,"`n" -join ''
$output += "Job Name: ",$BEServer.JobName,"`n" -join ''
$output += "Job Status: ",$BEServer.JobStatus," - ",$BEServer.SubStatus,"`n" -join ''
$output += "Time: ",$BEServer.StartTime,"-",$BEServer.EndTime," (",$BEServer.ElapsedTime,")`n" -join ''
$output += "% Complete: ",$BEServer.PercentComplete,"`n`n" -join ''
}
This results in the following for a failed job:
Server Name: Server01
Job Name: Daily Backups-XYZ_Policy
Job Status: Canceled -
Time: 1/1/2013 10:00:02 PM-1/1/2013 10:26:18 PM (00:26:16)
% Complete: -1
Basically, althrough Get-BEJob provides SubStatus, Get-BEJobHistory does not, and this means I have very little to go on for why a job failed.
SubStatus is an enumerated list whose values can be found here: http://www.symantec.com/connect/blogs/get-bejob-substatus-and-other-properties[2] (about halfway down).
The properties of Get-JobHistory do not appear to include any error codes, etc. that would help be find this out.
Basically, I want to reduce the need to connect to a remote server in order to start investigating the failure, since I've got ~50 BE installations in two countries and need to streamline the process.
Any advice on this would be welcome!
01-04-2013 02:21 PM
01-07-2013 11:08 AM
Thanks for getting back to me.
When I run the code, the result in $BEServer contains the following (anonymized):
PSComputerName : server01 RunspaceId : e22068d9-3c9d-40af-afe1-e2d44698cc4d PSShowComputerName : True Name : Daily Backups-XYZ_Policy Id : 906aa413-7ed9-40ec-b5ca-d297545033c6 JobName : Daily Backups-XYZ_Policy JobStatus : Canceled StartTime : 1/4/2013 10:00:03 PM EndTime : 1/4/2013 10:32:48 PM ElapsedTime : 00:32:45 TotalDataSizeBytes : 0 JobRateMBPerMinute : -1 DeduplicationRatio : 0 JobType : Backup PercentComplete : -1 StorageName : BackupExecServerName : server01 Job : Daily Backups-XYZ_Policy JobId : 326ddcca-09e7-4565-bc4c-9083731cb0ac AgentServer : server01.mydomain.ca AgentServerId : 5a9faf22-d7ee-4f1f-94bf-bf17802a7a5f JobLogFilePath : C:\Program Files\Symantec\Backup Exec\Data\BEX_server01_00496.xml ErrorCode : 0 ErrorCategory : 1
function Get-JobIdInfo { param( $serverName, $JobId ) "Server: $serverName" "ID: $JobId" $s = New-PSSession -ComputerName $serverName Invoke-Command -session $s { Import-Module "C:\Program Files\Symantec\Backup Exec\Modules\BEMCLI\BEMCLI" Get-BEJobHistory -Id $JobId } Remove-PSSession -session $s }
When I run that, using ID, JobId or RunSpaceId, I get the following error:
Cannot validate argument on parameter 'Id'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again. + CategoryInfo : InvalidData: (:) [Get-BEJobHistory], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,BackupExec.Management.CLI.Commands.GetBEJobHistoryCommand
01-07-2013 12:07 PM
What you're dealing with here is a nuance of Invoke-Command with PowerShell sessions. I cooked up the following test to illustrate:
function Test-Scope { param( $parameter ) # Show $parameter via inherited scope, and passed as an argument. Invoke-Command { param($parameterArg) "parameter : $parameter" "parameterArg : $parameterArg" } -ArgumentList $parameter # Try again, but in another session: $s = New-PSSession Invoke-Command { param($parameterArg) "Session parameter : $parameter" "Session parameterArg : $parameterArg" } -ArgumentList $parameter -Session $s } PS C:\Windows\system32> Test-Scope "hi" parameter : hi parameterArg : hi Session parameter : Session parameterArg : hi
The Session parameter case shows what's going on -- since you're invoking the command on a separate session, the $jobId needs to passed via the -ArgumentList parameter of Invoke-Command. You'll also want to add a param() block inside the scriptblock:
function Get-JobIdInfo { param( $serverName, $JobId ) "Server: $serverName" "ID: $JobId" $s = New-PSSession -ComputerName $serverName Invoke-Command -session $s { param($JobId) Import-Module "C:\Program Files\Symantec\Backup Exec\Modules\BEMCLI\BEMCLI" Get-BEJobHistory -Id $JobId } -ArgumentList $JobId Remove-PSSession -session $s }
I think that'll do it.
01-07-2013 03:30 PM
Thank you! Here's the result of that, with all properties:
Name : Daily Backups-XYZ_Policy Id : 906aa413-7ed9-40ec-b5ca-d297545033c6 JobName : Daily Backups-XYZ_Policy JobStatus : Canceled StartTime : 1/4/2013 10:00:03 PM EndTime : 1/4/2013 10:32:48 PM ElapsedTime : 00:32:45 TotalDataSizeBytes : 0 JobRateMBPerMinute : -1 DeduplicationRatio : 0 JobType : Backup PercentComplete : -1 StorageName : BackupExecServerName : server01 Job : Daily Backups-XYZ_Policy JobId : 326ddcca-09e7-4565-bc4c-9083731cb0ac AgentServer : server01.mydomain.ca AgentServerId : 5a9faf22-d7ee-4f1f-94bf-bf17802a7a5f JobLogFilePath : C:\Program Files\Symantec\Backup Exec\Data\BEX_server01_00496.xml ErrorCode : 0 ErrorCategory : 1 PSComputerName : server01 RunspaceId : d4d427b8-7b25-4432-b898-290ff583038c PSShowComputerName : True
I had thought initially that I was not getting the ErrorCode and ErrorCategory, but it just appears that the data in them is not useful...maybe? Do you have a list of what these values should correspond to?
01-29-2013 06:36 AM
I'm starting to deal with Powershell just for BECli and I find this post very interesting because I want to do a report like that. I'll keep my subscription to this post for further updates.