Return agent based jobs

PowerShell script exchange

Return agent based jobs

Veeam Logoby frankU32 » Thu May 03, 2018 7:46 am

Hello

I am trying to write a script that returns the JobID of some managed agent based jobs (windows and Linux) but the commands I use for normal jobs don't seem to show jobs of this type.

Usually, I would use
Get-VBRjob
Get-VBREPJob

but as I said, they don't list managed agent based jobs.
frankU32
Influencer
 
Posts: 15
Liked: never
Joined: Wed May 02, 2018 11:56 am
Full Name: Frank Tighe

Re: Return agent based jobs

Veeam Logoby Dima P. » Thu May 03, 2018 8:30 am 1 person likes this post

Hello Frank.

PowerShell support for managed agents is currently limited to protection group creation, so this behavior is expected, but it's going to be enhanced in next versions.
Dima P.
Veeam Software
 
Posts: 8233
Liked: 590 times
Joined: Mon Feb 04, 2013 2:07 pm
Location: Prague
Full Name: Dmitry Popov

Re: Return agent based jobs

Veeam Logoby frankU32 » Fri May 04, 2018 8:10 am

Thanks, is there another way to get the JobID for these jobs?
frankU32
Influencer
 
Posts: 15
Liked: never
Joined: Wed May 02, 2018 11:56 am
Full Name: Frank Tighe

Re: Return agent based jobs

Veeam Logoby tdewin » Fri May 04, 2018 8:20 am

yes, you can do it in a unsupported way. for example:
Code: Select all
PS C:\Users\Administrator> [Veeam.Backup.Core.CBackupJob]::GetAll() | ? { $_.JobType -match "EpAgent"} | select name,id,jobtype

Name            Id                                         JobType
----            --                                         -------
vbr             0fe95949-6658-4c74-8a4f-2d8ff673151e EpAgentBackup
Agent Backup AD 318697f3-60a9-4c55-a03c-a1324c32c692 EpAgentPolicy
lin             9327122b-1e75-49aa-bccb-b4a0b057c348 EpAgentBackup
Linux           7b066a8e-5da9-4b1d-ab7c-d26fb899df9a EpAgentBackup
tdewin
Veeam Software
 
Posts: 1286
Liked: 421 times
Joined: Fri Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin

[MERGED] Query Veeam Server Agent backups

Veeam Logoby Talom » Thu Jul 12, 2018 10:06 am

Hi,
i want to query all backup results from my Veeam server.
As far as i know it is not possible to get the results for backups from Veeam Agent for Server with powershell.
Does anyone know how to query the results directly from the database?
Talom
Influencer
 
Posts: 18
Liked: 1 time
Joined: Tue Oct 21, 2014 7:56 am

Re: Return agent based jobs

Veeam Logoby v.Eremin » Thu Jul 12, 2018 11:46 am

Above you can find some creative workarounds how to get information regarding agent management jobs. Thanks.
v.Eremin
Veeam Software
 
Posts: 14966
Liked: 1122 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Return agent based jobs

Veeam Logoby Talom » Thu Aug 09, 2018 8:40 am

Just a small CodeSnippet, how you can get all the necessary Objects to gather all informations about EPBackups.
Idk why but the GetBy functions don't return the complete objects so you have to reload them with Get
Code: Select all
  foreach($job in [Veeam.Backup.Core.CBackupJob]::GetAll() | ? { $_.JobType -match "EpAgent"}){
      try {
           
            if($job){
           
               $sessions += [veeam.backup.core.cbackupsession]::GetByJob($job.id)  | Where-Object { ($_.JobType -match 'EpAgent') -and  $_.EndTime -ge $date}
               
            }
        }catch [System.Exception] {
           write-Host $job.Name
        }
   }

        foreach($session in $sessions){
          $session = [veeam.backup.core.cbackupsession]::Get($session.Id, $job)
           

           $allSessionIds =  $session.AuxData | Select-String -Pattern 'Sessions=\".*\"'
         $allSessionIds=  $allSessionIds -replace '.*Sessions=\"', ''
         $allSessionIds=  $allSessionIds -replace '\" /><PolicyTask.*', ''
         $ids = $allSessionIds.ToString().Split(';',[System.StringSplitOptions]::RemoveEmptyEntries)

         
           foreach($sessionId in $ids){         
                      if($sessionId -ne 'System.Object[]' ){
                    $TaskSessions =  [Veeam.Backup.Core.CBackupTaskSession]::GetByJobSession($sessionId)
                       
                    foreach($TaskSession in $TaskSessions){
                   $TaskSession =  [Veeam.Backup.Core.CBackupTaskSession]::Get($TaskSession.Id, $session) 
                     $TaskInfo = $TaskSession.Info     
                     $WorkDetails = $TaskInfo.WorkDetails
                    }


                }
             }
         }
       


Talom
Influencer
 
Posts: 18
Liked: 1 time
Joined: Tue Oct 21, 2014 7:56 am

Re: Return agent based jobs

Veeam Logoby v.Eremin » Thu Aug 09, 2018 6:34 pm

Just so you know - all agent-specific commands will be available in Veeam PowerShell snap-in, starting from Update 4. Thanks.
v.Eremin
Veeam Software
 
Posts: 14966
Liked: 1122 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 5 guests