Hello.
Im trying to get the info from the tape barcodes used in the last run of a job or set of jobs (it can be a where using a daily media pool, for example) in powershell . Tried in Veeam One, but i cant get that info for the selected jobs displaying the last used tapes (or a query with period of time).
To be more clear , what im trying to do :
Name of the job, last run, creation date, Barcode used, media set (These info are all in the right click in a Job - Report)
i tried to use Get-VBRTapeMedium, but i can get only lastWriteTime, but not the job names
Tried Get-VBRTapeJob to get the ame, Type (Tape Job) and Media Set, LastResult, but i cant get the used media.
I dont know how to use both to get to the results that i need. Someone can give me a idea how to use both in the same powershell?
Thank you!
-
- Service Provider
- Posts: 26
- Liked: 6 times
- Joined: Dec 15, 2016 11:39 pm
- Contact:
-
- Veeam Software
- Posts: 2010
- Liked: 669 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Query name, last result and barcode from Tape Job
Hi @Rmachado,
I'm afraid I cannot find any direct bindings between tape backup sessions and tape medium neither in Powershell objects, nor in core .NET classes/methods to explicitly tell which ones were used here and there. The only and quite implicit relevance I found, which might help (or might not) is tape medium's LastWriteTime vs. tape backup session's EndTime. Comparing those datetimes and validating mediums used in a job we are acting on, I was able to get more or less specific info. Sample code:
Hope it can be of any help.
Thanks,
Oleg
I'm afraid I cannot find any direct bindings between tape backup sessions and tape medium neither in Powershell objects, nor in core .NET classes/methods to explicitly tell which ones were used here and there. The only and quite implicit relevance I found, which might help (or might not) is tape medium's LastWriteTime vs. tape backup session's EndTime. Comparing those datetimes and validating mediums used in a job we are acting on, I was able to get more or less specific info. Sample code:
Code: Select all
# Get backup to tape jobs
$job = Get-VBRTapeJob | where {$_.Type -eq 'BackupToTape'}
# Select last session for a tape job
$session = [Veeam.Backup.Core.CBackupSession]::GetByJob($job[1].Id) | select -Last 1
# Parse tape mediums with LastWriteTime =< session EndTime (but not less than 2 hours ago from session EndTime)
$mediums = Get-VBRTapeMedium | where {$_.LastWriteTime -le $session.EndTime -and $_.LastWriteTime -ge $session.EndTime.AddHours(-2)}
$summary = @()
foreach ($medium in $mediums) {
# Check if medium in question belongs to tape job's full backup media pool
foreach ($jobMedium in $job[1].FullBackupMediaPool.Medium) {
if ($medium.Barcode -eq $jobMedium.Barcode) {
# If it does, create custom object and add it to summary
$summary += $medium | select @{n='MediumUsed';e={$_.Name}}, @{n='JobMedium';e={$jobMedium}}, @{n='SessionName';e={$session.Name}}, @{n='SessionEndTime';e={$session.EndTime}}, @{n='MediumLastWriteTime';e={$medium.LastWriteTime}}, Barcode, Location, Capacity, FreeSpace, MediaSet
}
}
# Check if medium in question belongs to tape job's incremental backup media pool
foreach ($jobMedium in $job[1].IncrementalBackupMediaPool.Medium) {
if ($medium.Barcode -eq $jobMedium.Barcode) {
# If it does, create custom object and add it to summary
$summary += $medium | select @{n='MediumUsed';e={$_.Name}}, @{n='JobMedium';e={$jobMedium}}, @{n='SessionName';e={$session.Name}}, @{n='SessionEndTime';e={$session.EndTime}}, @{n='MediumLastWriteTime';e={$medium.LastWriteTime}}, Barcode, Location, Capacity, FreeSpace, MediaSet
}
}
}
Thanks,
Oleg
Who is online
Users browsing this forum: No registered users and 12 guests