PowerShell script exchange
Post Reply
manikb
Lurker
Posts: 1
Liked: never
Joined: Feb 19, 2019 1:02 am
Full Name: Manik Bedi
Contact:

unable to see last runtime or endtime in Powershell for Agent jobs

Post by manikb »

I am unable to get the last runtime for all the Agents on my Veeam Server. However, I can see the endtime (or last runtime) for an Agent session though which is not that helpful. Can someone help please?

PS C:\Users\manikb> asnp VeeamPSSnapin
PS C:\Users\manikb> Get-VBREPSession | gm


TypeName: Veeam.Backup.PowerShell.Infos.VBRSession

Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
CreationTime Property datetime CreationTime {get;}
EndTime Property System.Nullable[datetime] EndTime {get;}
Id Property guid Id {get;}
JobId Property guid JobId {get;}
Result Property Veeam.Backup.PowerShell.Infos.VBRSessionResult Result {get;}
State Property Veeam.Backup.PowerShell.Infos.VBRSessionState State {get;}


PS C:\Users\manikb> Get-VBREPjob | gm


TypeName: Veeam.Backup.PowerShell.Infos.VBREPJob

Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetPlatforn Method Veeam.Backup.Common.EPlatform GetPlatforn()
GetType Method type GetType()
ToString Method string ToString()
Description Property string Description {get;}
Id Property guid Id {get;}
IsEnabled Property bool IsEnabled {get;}
LastResult Property Veeam.Backup.PowerShell.Infos.VBRSessionResult LastResult {get;}
LastState Property Veeam.Backup.PowerShell.Infos.VBRSessionState LastState {get;}
Name Property string Name {get;}
NextRun Property System.Nullable[datetime] NextRun {get;}
ObjectsCount Property int ObjectsCount {get;}
RepositoryId Property System.Nullable[guid] RepositoryId {get;}
Target Property System.Object Target {get;}
Type Property Veeam.Backup.PowerShell.Infos.VBRJobType Type {get;}
Talom
Enthusiast
Posts: 43
Liked: 6 times
Joined: Oct 21, 2014 7:56 am
Contact:

Re: unable to see last runtime or endtime in Powershell for Agent jobs

Post by Talom »

Thats how i do it

Code: Select all

        $sessions = @()
    # Abfrage von Veeam Agents bzw. Veeam Endpoint
    $backups = Get-VBRBackup | Where-Object { $_.JobType -eq 'EndpointBackup'}
    foreach($b in $backups) {
        try{

            $job = $b.FindJob()
	        if($job){
	            $sessions += $job.FindLastSession() | Where-Object { $_.JobType -eq 'EndpointBackup' -and  $_.EndTime -ge $date}
	        }
        }catch [System.Exception] {
            write-Host $job.Name
        }
    }

$progressSession = $session.Progress
		$startTime = $progressSession.StartTime
		$stopTime = $progressSession.StopTime
		if(!$startTime){
			$temp = $progressSession.StartTimeLocal
			if($temp){
			$startTime = Get-Date $progressSession.StartTimeLocal
			}
		}
		if(!$stopTime){
		$temp = $progressSession.StopTimeLocal
		if($temp){
			$stopTime = Get-Date $progressSession.StopTimeLocal
			}
			
		}
BACKUP EAGLE® Developer
Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests