PowerShell script exchange
Post Reply
frankU32
Enthusiast
Posts: 36
Liked: 2 times
Joined: May 02, 2018 11:56 am
Full Name: Frank Tighe
Contact:

Return agent based jobs

Post by frankU32 »

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.
Dima P.
Product Manager
Posts: 14415
Liked: 1576 times
Joined: Feb 04, 2013 2:07 pm
Full Name: Dmitry Popov
Location: Prague
Contact:

Re: Return agent based jobs

Post by Dima P. » 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.
frankU32
Enthusiast
Posts: 36
Liked: 2 times
Joined: May 02, 2018 11:56 am
Full Name: Frank Tighe
Contact:

Re: Return agent based jobs

Post by frankU32 »

Thanks, is there another way to get the JobID for these jobs?
tdewin
Veeam Software
Posts: 1775
Liked: 646 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Return agent based jobs

Post by tdewin »

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
Talom
Enthusiast
Posts: 43
Liked: 6 times
Joined: Oct 21, 2014 7:56 am
Contact:

[MERGED] Query Veeam Server Agent backups

Post by Talom »

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?
BACKUP EAGLE® Developer
veremin
Product Manager
Posts: 20283
Liked: 2257 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Return agent based jobs

Post by veremin »

Above you can find some creative workarounds how to get information regarding agent management jobs. Thanks.
Talom
Enthusiast
Posts: 43
Liked: 6 times
Joined: Oct 21, 2014 7:56 am
Contact:

Re: Return agent based jobs

Post by Talom »

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
                    }


                }
             }
         }
        


BACKUP EAGLE® Developer
veremin
Product Manager
Posts: 20283
Liked: 2257 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Return agent based jobs

Post by veremin »

Just so you know - all agent-specific commands will be available in Veeam PowerShell snap-in, starting from Update 4. Thanks.
Florian_Kromer
Novice
Posts: 5
Liked: never
Joined: Dec 20, 2018 10:02 am

Re: Return agent based jobs

Post by Florian_Kromer »

@v.Eremin

Is Veeam PowerShell snap-in Update 4 already available?
Can I get the information which PS snap-in Update version in a PS script?
veremin
Product Manager
Posts: 20283
Liked: 2257 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Return agent based jobs

Post by veremin »

It gets installed by default with product update. Thanks!
Talom
Enthusiast
Posts: 43
Liked: 6 times
Joined: Oct 21, 2014 7:56 am
Contact:

Re: Return agent based jobs

Post by Talom »

FYI the snippet still works with Update 4.
I won't use the new agent commands because i have to support multiple Veeam versions.
BACKUP EAGLE® Developer
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests