-
- Enthusiast
- Posts: 48
- Liked: 1 time
- Joined: Jan 01, 2006 1:01 am
- Contact:
Duration Job
Hi
I try to get the Duration of all my jobs:
This one is working, if I mention one 1 job:
$vbrjobname = "T1 VM1"
$job = Get-VBRJob | ?{$_.Name -eq $vbrjobname}
$session = Get-VBRBackupSession | ?{$_.Name -eq $job.Name}
$Duration = $session.EndTime - $session.CreationTime
$TimeSpan = $Duration
$Duration = '{0:00}:{1:00}:{2:00}' -f $TimeSpan.Hours, $TimeSpan.Minutes, $TimeSpan.Seconds
Write-Host $Duration
This one is not working, if I mention several jobs that start with T1
Get-VBRJob | where {$_.name.StartsWith("T1")} | foreach {
$vbrjobname = "TECH2 PrivateLuc"
$job = Get-VBRJob | ?{$_.Name -eq $vbrjobname}
$session = Get-VBRBackupSession | ?{$_.Name -eq $job.Name}
$Duration = $session.EndTime - $session.CreationTime
$TimeSpan = $Duration
$Duration = '{0:00}:{1:00}:{2:00}' -f $TimeSpan.Hours, $TimeSpan.Minutes, $TimeSpan.Seconds
Write-Host $vbrjobname + $Duration
}
What it is Wrong?
Many thanks for your help
I try to get the Duration of all my jobs:
This one is working, if I mention one 1 job:
$vbrjobname = "T1 VM1"
$job = Get-VBRJob | ?{$_.Name -eq $vbrjobname}
$session = Get-VBRBackupSession | ?{$_.Name -eq $job.Name}
$Duration = $session.EndTime - $session.CreationTime
$TimeSpan = $Duration
$Duration = '{0:00}:{1:00}:{2:00}' -f $TimeSpan.Hours, $TimeSpan.Minutes, $TimeSpan.Seconds
Write-Host $Duration
This one is not working, if I mention several jobs that start with T1
Get-VBRJob | where {$_.name.StartsWith("T1")} | foreach {
$vbrjobname = "TECH2 PrivateLuc"
$job = Get-VBRJob | ?{$_.Name -eq $vbrjobname}
$session = Get-VBRBackupSession | ?{$_.Name -eq $job.Name}
$Duration = $session.EndTime - $session.CreationTime
$TimeSpan = $Duration
$Duration = '{0:00}:{1:00}:{2:00}' -f $TimeSpan.Hours, $TimeSpan.Minutes, $TimeSpan.Seconds
Write-Host $vbrjobname + $Duration
}
What it is Wrong?
Many thanks for your help
-
- Veteran
- Posts: 282
- Liked: 26 times
- Joined: Nov 10, 2010 6:51 pm
- Full Name: Seth Bartlett
- Contact:
Re: Duration Job
Code: Select all
Get-VBRJob | where {$_.name.StartsWith("T1")} | foreach {
$vbrjobname = "TECH2 PrivateLuc"
$job = Get-VBRJob | ?{$_.Name -eq $vbrjobname}
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
-
- Enthusiast
- Posts: 48
- Liked: 1 time
- Joined: Jan 01, 2006 1:01 am
- Contact:
Re: Duration Job
Sorry it was during my test, if I run this, it is not working either:
Get-VBRJob | where {$_.name.StartsWith("T1")} | foreach {
$vbrjobname = $_.Name
$job = Get-VBRJob | ?{$_.Name -eq $vbrjobname}
$session = Get-VBRBackupSession | ?{$_.Name -eq $job.Name}
$Duration = $session.EndTime - $session.CreationTime
$TimeSpan = $Duration
$Duration = '{0:00}:{1:00}:{2:00}' -f $TimeSpan.Hours, $TimeSpan.Minutes, $TimeSpan.Seconds
Write-Host $vbrjobname + $Duration
}
Get-VBRJob | where {$_.name.StartsWith("T1")} | foreach {
$vbrjobname = $_.Name
$job = Get-VBRJob | ?{$_.Name -eq $vbrjobname}
$session = Get-VBRBackupSession | ?{$_.Name -eq $job.Name}
$Duration = $session.EndTime - $session.CreationTime
$TimeSpan = $Duration
$Duration = '{0:00}:{1:00}:{2:00}' -f $TimeSpan.Hours, $TimeSpan.Minutes, $TimeSpan.Seconds
Write-Host $vbrjobname + $Duration
}
-
- Veteran
- Posts: 282
- Liked: 26 times
- Joined: Nov 10, 2010 6:51 pm
- Full Name: Seth Bartlett
- Contact:
Re: Duration Job
What data do you get? Is it just blank with the name? When I run that, I get some blank data but I know those jobs haven't ran.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
-
- Enthusiast
- Posts: 48
- Liked: 1 time
- Joined: Jan 01, 2006 1:01 am
- Contact:
Re: Duration Job
This is what I get:
T1 VM1 + ::
T1 VM2 + ::
T1 VM3 + ::
T1 VM4 + ::
I do not get the duration, thanks
T1 VM1 + ::
T1 VM2 + ::
T1 VM3 + ::
T1 VM4 + ::
I do not get the duration, thanks
-
- Veteran
- Posts: 282
- Liked: 26 times
- Joined: Nov 10, 2010 6:51 pm
- Full Name: Seth Bartlett
- Contact:
Re: Duration Job
Have all these jobs ran? When I run it, it works for me. Just tested it out again.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
-
- VP, Product Management
- Posts: 6035
- Liked: 2860 times
- Joined: Jun 05, 2009 12:57 pm
- Full Name: Tom Sightler
- Contact:
Re: Duration Job
I think the problem is these commands:
The $session variable will be populated with all sessions from the selected job, which is going to make the calculation for $Duration unpredictable at best. I'm assuming you are wanting the most recent session for the job so I'd say something like this is probably more likely to work reliably:
Code: Select all
$session = Get-VBRBackupSession | ?{$_.Name -eq $job.Name}
$Duration = $session.EndTime - $session.CreationTime
Code: Select all
$session = $job.findlastsession()
$Duration = $session.EndTime - $session.CreationTime
-
- Veteran
- Posts: 282
- Liked: 26 times
- Joined: Nov 10, 2010 6:51 pm
- Full Name: Seth Bartlett
- Contact:
Re: Duration Job
Oh derp, nice Tom, I completely forgot the Get-VBRBackupSession would give a complete array and it's grabbing no data from the whole array rather than the most recent object. I missed that too
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
Who is online
Users browsing this forum: No registered users and 17 guests