PowerShell script exchange
Post Reply
AllSorts
Lurker
Posts: 1
Liked: never
Joined: Dec 30, 2015 7:45 pm
Full Name: Rob Carr
Contact:

Super Simple Get-VBRBackupSession

Post by AllSorts »

Looking for something really simply in Powershell to do the follow:

Show all jobs run in the last 30 days. I need the name, type (backup or duplicate), date run, status and amount of data each job backed up or duplicated to tape. All the PS scripts I've seen are way too complicated for what I need. I've been trying to get objects out of Get-VBRBackupSession but haven't been successful yet at getting all the info I need. Could someone please point me in the right direction.

Thanks.
tsightler
VP, Product Management
Posts: 6009
Liked: 2843 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Super Simple Get-VBRBackupSession

Post by tsightler »

I believe this little one-liner gets a lot of what you need, although I don't think tape sessions are returned by Get-VBRBackupSession so that might need something else:

Code: Select all

Get-VBRBackupSession | ?{$_.CreationTime -ge (Get-Date).AddDays(-30)} | Select JobName, JobType, CreationTime, Result, @{Name="BackupSize";Expression={$_.BackupStats.BackupSize}} | Sort CreationTime | Format-Table
BTW, I'm not sure if you wanted source data size or backup data size after compression/dedupe, so I went with the latter. If you want the size of the source data you can change BackupSize to DataSize.
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Super Simple Get-VBRBackupSession

Post by veremin »

Also, Get-VBRBackupSession doesn't return tape job sessions, in order to get them leverage Get-VBRSession commandlet. Thanks.
javierjq
Lurker
Posts: 1
Liked: never
Joined: Aug 24, 2021 5:27 pm
Full Name: javier juarez
Contact:

Re: Super Simple Get-VBRBackupSession

Post by javierjq »

Good Tip
what if I want the Duration time of each Job ?
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Super Simple Get-VBRBackupSession

Post by oleg.feoktistov »

Then you can subtract tape session creation time from its end time since no Duration property exists in the type retrieved with Get-VBRSession:

Code: Select all

$tapeJob = Get-VBRTapeJob
$tapeSession = Get-VBRSession -Job $tapeJob
$duration = $tapeSession.EndTime - $tapeSession.CreationTime
$duration.ToString()
Thanks!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 18 guests