Discussions related to exporting backups to tape and backing up directly to tape.
Post Reply
fafa24
Enthusiast
Posts: 74
Liked: 6 times
Joined: Jun 14, 2015 4:48 pm
Contact:

Powershell script to inventory and eject

Post by fafa24 »

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: 6551
Liked: 765 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Powershell script to inventory and eject

Post by PTide »

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: 74
Liked: 6 times
Joined: Jun 14, 2015 4:48 pm
Contact:

Re: Powershell script to inventory and eject

Post by fafa24 »

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
Veteran
Posts: 391
Liked: 107 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 »

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: 14726
Liked: 1707 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. »

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: 74
Liked: 6 times
Joined: Jun 14, 2015 4:48 pm
Contact:

Re: Powershell script to inventory and eject

Post by fafa24 »

The Out-Null did not work. I will try Start-Sleep command.
JaxIsland7575
Veteran
Posts: 391
Liked: 107 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 »

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

Cheers!
VMCE v9
Yury.Panchenko
Veeam Software
Posts: 11
Liked: 5 times
Joined: Jun 26, 2014 8:10 am
Full Name: Yury Panchenko
Contact:

Re: Powershell script to inventory and eject

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

Re: Powershell script to inventory and eject

Post by veremin »

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 »

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

Re: Powershell script to inventory and eject

Post by veremin »

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