Import VBRTapeMedium with log of tapes imported

PowerShell script exchange

Import VBRTapeMedium with log of tapes imported

Veeam Logoby pvr2002 » Mon Feb 27, 2017 9:38 pm

I am currently utilizing a script to import tapes automatically using the command:
Code: Select all
Get-VBRTapeLibrary -Name "ScalarName" | Import-VBRTapeMedium -Wait


The command functions properly, but I'd like to be able to save the barcodes that were imported into a variable to e-mail back to me. Any ideas how to pull the barcodes of the imported tapes?
pvr2002
Novice
 
Posts: 8
Liked: never
Joined: Mon Feb 27, 2017 8:50 pm

Re: Import VBRTapeMedium with log of tapes imported

Veeam Logoby v.Eremin » Tue Feb 28, 2017 10:13 am

If I'm not mistaken, an object of VBRBackupSession type is returned by Import-VBRTapemedium cmdlet. VBRBackupSession has log parameter. I think you can easily parse it and see what tapes have been imported. Thanks.
v.Eremin
Veeam Software
 
Posts: 13558
Liked: 1006 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Import VBRTapeMedium with log of tapes imported

Veeam Logoby pvr2002 » Tue Feb 28, 2017 1:48 pm

I looked at the VBRBackupSession command and received a lot of entries back. However I only get 2 different job types. "Backup" and "BackupSync". I don't see anything relating to Importing.
pvr2002
Novice
 
Posts: 8
Liked: never
Joined: Mon Feb 27, 2017 8:50 pm

Re: Import VBRTapeMedium with log of tapes imported

Veeam Logoby v.Eremin » Tue Feb 28, 2017 2:47 pm

You need to assign result of Import-VBRTapeMedium cmdlet to a variable and then parse log of resulting object. Something like:

Code: Select all
$ImportSession.logger.getlog().updatedrecords.title

Thanks.
v.Eremin
Veeam Software
 
Posts: 13558
Liked: 1006 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Import VBRTapeMedium with log of tapes imported

Veeam Logoby pvr2002 » Tue Feb 28, 2017 4:05 pm

I appreciate the help, but so far am unable to get it to work.

I altered my code to the following:
Code: Select all
$ImportSession = (Get-VBRTapeLibrary -Name "ScalarName" | Import-VBRTapeMedium -Wait)
write $ImportSession
$ImportSession.logger.getlog().updatedrecords.title


$ImportSession contains the following:
Progress : 100
RunManually : True
Log : {1, 2, 3, 4...}
CreationTime : 2/28/2017 9:54:35 AM
EndTime : 2/28/2017 9:54:56 AM
JobId : 06dc4f95-37d6-4a2d-8108-9ea5a99b3e02
Result : Success
State : Stopped
Id : 06dc4f95-37d6-4a2d-8108-9ea5a99b3e02

$ImportSession.logger.getlog().updatedrecords.title give me an error:
You cannot call a method on a null-valued expression.
pvr2002
Novice
 
Posts: 8
Liked: never
Joined: Mon Feb 27, 2017 8:50 pm

Re: Import VBRTapeMedium with log of tapes imported

Veeam Logoby v.Eremin » Wed Mar 01, 2017 11:46 am

Coding from memory does not always work as expected. Anyway, the following code should output all log entities an import session generate:

Code: Select all
asnp VeeamPSSnapin
$Library = Get-VBRTapeLibrary -Name "Name of your tape library"
$Session = $Library | Import-VBRTapeMedium -Wait
$Session.Log | select title

Among those should be one with barcodes of imported tapes.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13558
Liked: 1006 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Import VBRTapeMedium with log of tapes imported

Veeam Logoby pvr2002 » Thu Mar 02, 2017 1:33 pm

That code works great, unfortunately the session.log data doesn't include tape numbers.

Id : 1
Usn : 1
Title : Job started at 3/1/2017 4:51:17 PM
Cookie :
Description :
Time : 3/1/2017 4:51:18 PM
StartTime : 3/1/2017 4:51:18 PM
Status : Succeeded

Id : 2
Usn : 2
Title : Found 1 tapes for import in I/E ports
Cookie :
Description :
Time : 3/1/2017 4:51:23 PM
StartTime : 3/1/2017 4:51:23 PM
Status : Succeeded

Id : 3
Usn : 5
Title : Importing tape from I/E port 1 to Slot 15
Cookie :
Description :
Time : 3/1/2017 4:51:45 PM
StartTime : 3/1/2017 4:51:24 PM
Status : Succeeded
pvr2002
Novice
 
Posts: 8
Liked: never
Joined: Mon Feb 27, 2017 8:50 pm

Re: Import VBRTapeMedium with log of tapes imported

Veeam Logoby v.Eremin » Fri Mar 03, 2017 10:34 am

Damn, I'm running out of ideas. :)

Do all of your imported tapes go directly to Imported media pool or sometimes you import media written by 3-party vendor and therefore some cassettes appear in Unrecognized media pool?

Actually, in both cases you can do the following:

1) Get tapes (if any is present) in Unrecognized and Imported media pools.
2) Assign result to variable
3) Import tapes
4) Get tapes (if any is present) in Unrecognized and Imported media pools.
5) Assign result to variable
6) Compare two variable, a difference will be represented by newly imported tapes

Thanks.
v.Eremin
Veeam Software
 
Posts: 13558
Liked: 1006 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Import VBRTapeMedium with log of tapes imported

Veeam Logoby pvr2002 » Thu Mar 09, 2017 9:42 pm

That worked for me.

Thanks again for the help.
pvr2002
Novice
 
Posts: 8
Liked: never
Joined: Mon Feb 27, 2017 8:50 pm

Re: Import VBRTapeMedium with log of tapes imported

Veeam Logoby v.Eremin » Fri Mar 10, 2017 11:30 am

Glad to hear that the proposed scenario works for you. Should other help be needed, don't hesitate to let us know.
v.Eremin
Veeam Software
 
Posts: 13558
Liked: 1006 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 2 guests