PowerShell script exchange
Post Reply
pvr2002
Influencer
Posts: 10
Liked: never
Joined: Feb 27, 2017 8:50 pm
Contact:

Import VBRTapeMedium with log of tapes imported

Post by pvr2002 »

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?
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Import VBRTapeMedium with log of tapes imported

Post by veremin »

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.
pvr2002
Influencer
Posts: 10
Liked: never
Joined: Feb 27, 2017 8:50 pm
Contact:

Re: Import VBRTapeMedium with log of tapes imported

Post by pvr2002 »

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.
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Import VBRTapeMedium with log of tapes imported

Post by veremin »

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.
pvr2002
Influencer
Posts: 10
Liked: never
Joined: Feb 27, 2017 8:50 pm
Contact:

Re: Import VBRTapeMedium with log of tapes imported

Post by pvr2002 »

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.
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Import VBRTapeMedium with log of tapes imported

Post by veremin »

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.
pvr2002
Influencer
Posts: 10
Liked: never
Joined: Feb 27, 2017 8:50 pm
Contact:

Re: Import VBRTapeMedium with log of tapes imported

Post by pvr2002 »

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
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Import VBRTapeMedium with log of tapes imported

Post by veremin »

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.
pvr2002
Influencer
Posts: 10
Liked: never
Joined: Feb 27, 2017 8:50 pm
Contact:

Re: Import VBRTapeMedium with log of tapes imported

Post by pvr2002 »

That worked for me.

Thanks again for the help.
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Import VBRTapeMedium with log of tapes imported

Post by veremin »

Glad to hear that the proposed scenario works for you. Should other help be needed, don't hesitate to let us know.
ithark
Enthusiast
Posts: 40
Liked: 6 times
Joined: Sep 30, 2020 11:22 am
Full Name: Karthik
Contact:

Script for Veeam tape import

Post by ithark »

Dear Team,
We are trying to schedule a Veeam Import job for the tapes to be imported from the mail slots. Here, I am looking for a powershell script using which we can schedule this import and also to provide us the label name of the tapes which were imported.
I know that the following would import it but I am just not sure how I can list out the tapes which were imported.

Code: Select all

 Get-VBRTapeLibrary -Name "Library name" | Import-VBRTapeMedium -Wait
Thanks you so much.
Regards,
Karthik
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: Script for Veeam tape import

Post by Natalia Lupacheva »

Hi Karthik,

do these logs meet your requirements?
Also, there is a discussion in another thread.

thanks!
ithark
Enthusiast
Posts: 40
Liked: 6 times
Joined: Sep 30, 2020 11:22 am
Full Name: Karthik
Contact:

Re: Script for Veeam tape import

Post by ithark »

Hi @Natalia Lupacheva
Appreciate your reply.
I have already read those threads. The first one doesn't fetch me the tape names unfortunately and the next one is for importing new tapes but in my case, I will be importing the already used tapes.
Regards,
Karthik
Regards,
Karthik
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Script for Veeam tape import

Post by veremin »

My last reply in the first thread (the one about comparing tapes in Imported media pool) should do the trick, shouldn't it? Thanks!
ithark
Enthusiast
Posts: 40
Liked: 6 times
Joined: Sep 30, 2020 11:22 am
Full Name: Karthik
Contact:

Re: Script for Veeam tape import

Post by ithark »

Hi @veremin
Thanks for your reply. As I mentioned before, we will be reusing the old tapes and hence we don't we have to scan for the tapes in Unrecognized and Imported media pools.
They should all be already assigned to a particular media pool already.
Also, my power-shell expertise is not yet up to the point where I can create something on my own from scratch. Hence any help would be much appreciated.
Regards,
Karthik
Natalia Lupacheva
Veteran
Posts: 1143
Liked: 302 times
Joined: Apr 27, 2020 12:46 pm
Full Name: Natalia Lupacheva
Contact:

Re: Import VBRTapeMedium with log of tapes imported

Post by Natalia Lupacheva »

Hi @ithark,

merged the posts from your thread to the existing one since now it's clear we are talking about this script modification.
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Import VBRTapeMedium with log of tapes imported

Post by oleg.feoktistov »

@ithark,

I think, @veremin meant this:

Code: Select all

 
# Get unrecognized media pool along with the tapes within
$unrecognized = Get-VBRTapeMediaPool -Name 'Unrecognized'
$unrecognizedTapes = Get-VBRTapeMedium -MediaPool $unrecognized

# Import new tapes added to an existing library
$import = Import-VBRTapeMedium -Library $library -Wait

# Wait until DB is populated with new tapes records
Start-Sleep -Seconds 10

# Get the list of tapes from Unrecognized Media Pool once again
$unrecognizedTapesNew = Get-VBRTapeMedium -MediaPool $unrecognized 

# Compare old list with a new one
PS C:\Users\Administrator> Compare-Object -ReferenceObject $unrecognizedTapes -DifferenceObject $unrecognizedTapesNew

InputObject SideIndicator
----------- -------------
BAR6C94CA   =>           
BAR6F94C9   =>      
As you can see, in this case barcodes of the newly imported tapes are visible.

Best regards,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests