Powershell script to inventory and eject

Everything about backing up to tape

Powershell script to inventory and eject

Veeam Logoby fafa24 » Wed 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,
fafa24
Enthusiast
 
Posts: 50
Liked: 3 times
Joined: Sun Jun 14, 2015 4:48 pm

Re: Powershell script to inventory and eject

Veeam Logoby PTide » Wed 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.
PTide
Veeam Software
 
Posts: 3019
Liked: 246 times
Joined: Tue May 19, 2015 1:46 pm

Re: Powershell script to inventory and eject

Veeam Logoby fafa24 » Wed 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
fafa24
Enthusiast
 
Posts: 50
Liked: 3 times
Joined: Sun Jun 14, 2015 4:48 pm

Re: Powershell script to inventory and eject

Veeam Logoby JaxIsland7575 » Wed 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
JaxIsland7575
Veeam Vanguard
 
Posts: 364
Liked: 98 times
Joined: Mon Apr 27, 2015 1:59 pm
Location: NY, USA
Full Name: Ryan Jacksland

Re: Powershell script to inventory and eject

Veeam Logoby Dima P. » Wed 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
Dima P.
Veeam Software
 
Posts: 6242
Liked: 440 times
Joined: Mon Feb 04, 2013 2:07 pm
Location: SPb
Full Name: Dmitry Popov

Re: Powershell script to inventory and eject

Veeam Logoby fafa24 » Wed Aug 05, 2015 4:40 pm

The Out-Null did not work. I will try Start-Sleep command.
fafa24
Enthusiast
 
Posts: 50
Liked: 3 times
Joined: Sun Jun 14, 2015 4:48 pm

Re: Powershell script to inventory and eject

Veeam Logoby JaxIsland7575 » Thu Aug 06, 2015 8:38 pm

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

Cheers!
VMCE v9
JaxIsland7575
Veeam Vanguard
 
Posts: 364
Liked: 98 times
Joined: Mon Apr 27, 2015 1:59 pm
Location: NY, USA
Full Name: Ryan Jacksland

Re: Powershell script to inventory and eject

Veeam Logoby Yury.Panchenko » Fri 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)
Yury.Panchenko
Veeam Software
 
Posts: 2
Liked: 3 times
Joined: Thu Jun 26, 2014 8:10 am
Full Name: Yury Panchenko

Re: Powershell script to inventory and eject

Veeam Logoby v.Eremin » Tue 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.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

[MERGED] : Eject after Inventory

Veeam Logoby Lagcat » Wed 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
Lagcat
Influencer
 
Posts: 14
Liked: never
Joined: Tue Mar 31, 2015 9:17 am
Full Name: Jake Ryan

Re: Powershell script to inventory and eject

Veeam Logoby v.Eremin » Wed Feb 17, 2016 2:36 pm

Hi, Jake, kindly, check the script provided above and see whether it answers your requirements. Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to Tape



Who is online

Users browsing this forum: No registered users and 2 guests