BEMCLI Script To Import Tape Into The First Empty Slot
Created: 03 Apr 2012 • Updated: 11 Jun 2012 | 4 comments
This Powershell script is a follow-up to my earlier script
to import tapes into the first empty slot of a tape library.
With the advent of BE 2012 and the introduction of BEMCLI, the earlier script which is based on BEMCMD cannot be used in BE 2012. Since BEMCLI has a richer set of cmdlets, this script also clears the media intervention alert asking you to put a tape into the mail/io slot. Previously, this clearance is not possible and it resulted in a 20 minutes wait for the alert to expire which eats into the backup window.
This script would not have been possible with the many contributions from Martin Hess who also tested it.
To use this script, make sure that you have changed your Powershell execution policy so that you can run scripts. See my article below on how to do so
Before you use, you need to find out the name of your tape library. Launch BEMCLI and then issue this command.
Get-BERoboticLibraryDevice | Select-Object name
You would need the name of the library as an input parameter to the script.
If you have imported the BEMCLI module in your profile, then you can comment out the Import-Module command in the script.
To run the script as a pre-/post-command, use a statement like this
c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe 'c:\Import-FirstEmptySlot.ps1' '"HP 002"'
This assumes that the script is kept in the root directory of the C: drive. The library name, e.g. HP 002, must be surrounded by single quotes (') and the double-quotes (").