Discussions specific to tape backups
Post Reply
fafa24
Enthusiast
Posts: 61
Liked: 5 times
Joined: Jun 14, 2015 4:48 pm
Contact:

Powershell script to inventory and eject

Post by fafa24 » Aug 05, 2015 2:58 pm

Dear All,

We are rotating every weekday our tapes and would like to run a inventory job followed by an eject. I have created a powershell script.
asnp VeeamPSSnapin
$Library = Get-VBRTapeLibrary -name "HP 1x8 G2 AUTOLDR 3.10"
$Library | Start-VBRTapeInventory
Eject-VBRTapeMedium
The script inventories the tapes, but does not eject the last tape from the drive. I guess the powershell script ends before executing all commands. How could I instruct the script to wait until the "Start-VBRTapeInventory is finished?

Thanks,

PTide
Product Manager
Posts: 4876
Liked: 409 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Powershell script to inventory and eject

Post by PTide » Aug 05, 2015 3:09 pm

Hi,
I guess the powershell script ends before executing all commands.
Could you double check that please? I'd put an 'echo' output to file after each command to see where the script stops.

Thank you.

fafa24
Enthusiast
Posts: 61
Liked: 5 times
Joined: Jun 14, 2015 4:48 pm
Contact:

Re: Powershell script to inventory and eject

Post by fafa24 » Aug 05, 2015 3:20 pm

I think it runs all commands, but the eject command will be executed before the tape inventory ends.

I'm not so good in powershell to instruct a command to wait

JaxIsland7575
Veeam Vanguard
Posts: 384
Liked: 103 times
Joined: Apr 27, 2015 1:59 pm
Full Name: Ryan Jacksland
Location: NY, USA
Contact:

Re: Powershell script to inventory and eject

Post by JaxIsland7575 » Aug 05, 2015 3:30 pm

If you know how long you want it to wait before ejecting you could try:

Code: Select all

Start-Sleep -s 120
That would wait for 120 seconds. Ideally you would want to try and script it to verify its done and that would take a different approach. I have not done this myself so I apologize that I cannot be of more help. There is also a PowerShell forum http://forums.veeam.com/powershell-f26/ that may be of use.

Cheers!
VMCE v9

Dima P.
Product Manager
Posts: 9605
Liked: 755 times
Joined: Feb 04, 2013 2:07 pm
Full Name: Dmitry Popov
Location: Prague
Contact:

Re: Powershell script to inventory and eject

Post by Dima P. » Aug 05, 2015 3:57 pm

I belive sleep it valid, but a bit excess. You can try to pipeline to Out-Null instead and see if that works:

Code: Select all

$Library = Get-VBRTapeLibrary -name "HP 1x8 G2 AUTOLDR 3.10" 
$Library | Start-VBRTapeInventory | Out-Null
Eject-VBRTapeMedium

fafa24
Enthusiast
Posts: 61
Liked: 5 times
Joined: Jun 14, 2015 4:48 pm
Contact:

Re: Powershell script to inventory and eject

Post by fafa24 » Aug 05, 2015 4:40 pm

The Out-Null did not work. I will try Start-Sleep command.

JaxIsland7575
Veeam Vanguard
Posts: 384
Liked: 103 times
Joined: Apr 27, 2015 1:59 pm
Full Name: Ryan Jacksland
Location: NY, USA
Contact:

Re: Powershell script to inventory and eject

Post by JaxIsland7575 » Aug 06, 2015 8:38 pm

I was wondering if you were able to get this working or not?

Cheers!
VMCE v9

Yury.Panchenko
Veeam Software
Posts: 2
Liked: 3 times
Joined: Jun 26, 2014 8:10 am
Full Name: Yury Panchenko
Contact:

Re: Powershell script to inventory and eject

Post by Yury.Panchenko » Aug 07, 2015 9:02 am 3 people like this post

try this:

Code: Select all

asnp VeeamPSSnapin
$Library = Get-VBRTapeLibrary -name "HP 1x8 G2 AUTOLDR 3.10"
Start-VBRTapeInventory -Library $Library -Wait
Eject-VBRTapeMedium -Drive (Get-VBRTapeDrive -Library $Library)

v.Eremin
Product Manager
Posts: 15967
Liked: 1284 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Powershell script to inventory and eject

Post by v.Eremin » Aug 11, 2015 3:32 pm

Just to clarify:

Start-VBRTapeInventory is asynchronous call, meaning, PS proceeds to the next command right away.

That's why to make the said or similar calls wait you have to include -Wait switch designed specifically for such use cases.

Thanks.

Lagcat
Influencer
Posts: 16
Liked: never
Joined: Mar 31, 2015 9:17 am
Full Name: Jake Ryan
Contact:

[MERGED] : Eject after Inventory

Post by Lagcat » Feb 17, 2016 2:25 pm

Hello

i am running a few tape autoloaders in different countries which before all backups tape jobs i perform an inventory and move unrecognized tapes to free - chances are new tapes will get put in on some loaders so i run this job across all libraries

but at the end of the inventory job the tape is left in the drive

i wish to eject the last tape so the drive slot is empty before jobs begin

at the moment my power shell is like this:


Get-VBRTapeLibrary | Start-VBRTapeInventory

Get-VBRTapeDrive | Eject-VBRTapeMedium

Get-VBRTapeMedium -MediaPool unrecognized | Move-VBRTapeMedium -MediaPool Free

the problem is that the eject does not take place as the inventory is still running by the looks of things

is anyone able to clean this up for me?

Cheers

Jake

v.Eremin
Product Manager
Posts: 15967
Liked: 1284 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Powershell script to inventory and eject

Post by v.Eremin » Feb 17, 2016 2:36 pm

Hi, Jake, kindly, check the script provided above and see whether it answers your requirements. Thanks.

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests