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 » 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.

Dima P.
Product Manager
Posts: 10306
Liked: 834 times
Joined: Feb 04, 2013 2:07 pm
Full Name: Dmitry Popov
Location: Prague
Contact:

Re: Return agent based jobs

Post by Dima P. » 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.

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 » May 04, 2018 8:10 am

Thanks, is there another way to get the JobID for these jobs?

tdewin
Veeam Software
Posts: 1403
Liked: 457 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Return agent based jobs

Post by tdewin » 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

Talom
Influencer
Posts: 23
Liked: 2 times
Joined: Oct 21, 2014 7:56 am
Contact:

[MERGED] Query Veeam Server Agent backups

Post by Talom » 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?
BACKUP EAGLE® Developer

veremin
Product Manager
Posts: 16682
Liked: 1393 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Return agent based jobs

Post by veremin » Jul 12, 2018 11:46 am

Above you can find some creative workarounds how to get information regarding agent management jobs. Thanks.

Talom
Influencer
Posts: 23
Liked: 2 times
Joined: Oct 21, 2014 7:56 am
Contact:

Re: Return agent based jobs

Post by Talom » 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
                    }


                }
             }
         }
        


BACKUP EAGLE® Developer

veremin
Product Manager
Posts: 16682
Liked: 1393 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Return agent based jobs

Post by veremin » 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.

Florian_Kromer
Novice
Posts: 5
Liked: never
Joined: Dec 20, 2018 10:02 am
Contact:

Re: Return agent based jobs

Post by Florian_Kromer » Jan 15, 2019 3:07 pm

@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: 16682
Liked: 1393 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Return agent based jobs

Post by veremin » Jan 16, 2019 4:55 pm

It gets installed by default with product update. Thanks!

Talom
Influencer
Posts: 23
Liked: 2 times
Joined: Oct 21, 2014 7:56 am
Contact:

Re: Return agent based jobs

Post by Talom » Feb 04, 2019 2:49 pm

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: Majestic-12 [Bot] and 2 guests