To help manage my tape library inventory a bit better, the following script can be helpful to automatically make Backup Exec Inventory the Library and by running it from Windows Scheduler it is a set and forget operation. The tool also forms the basis for any other automation tasks you might need to implement later.

The powershell script below is similar to others I have written for BE automation and should be easy to follow, you can run it manually to test it. Otherwise create a file called inventory.bat and call the script from there.

The Script “inventory.ps1”:

cd "\Program Files\Symantec\Backup Exec"
# Get Library Name and get rid of blank lines in output
$a=.\bemcmd -o84 -j|where {$_ -ne ""}
# Seperate Device name
$o = $a[0].split(":")
$c=".\bemcmd -o117 -d"+'"'+$device+'"'
# execute the inventory
cmd /c $c

You can place this into a file called “inventory.ps1” and then create a DOS batch file to run the script from the DOS command line. The batch file just needs “powershell c:\unlock.ps1” in it. If the script comes up with an execution error then use set-executionpolicy unrestricted in a powershell window.

To Execute: “powershell c:\inventory-library.ps1, I put this in a .bat file and schedule it for lunchtime each day.