Backup Exec 2012 Tape Usage Report with PowerShell

Back in December 2011 Jeff Hicks posted this  drive usage console graph article on his blog. While I thought it was awesome, I was still learning PowerShell and didn’t understand how he achieved all of this.

Over the last couple of months I have kept coming back to this post. I wanted to implement the percentage free graph into something other then drive space.

Yesterday it hit me! While I was poking around in Backup Exec’s BEMCLI PowerShell module I noticed that you could pull stats from the tapes in the library. Doing this in itself is pretty easy, typing Get-BEMedia will get you all of the media available. Get-BEMedia –Name <Tape Name> will bring up the details for a specific tape.


Piping this command to Get-Member will give you all the properties you can pull information from.


The 2 properties we are after are TotalCapacityBytes and UsedCapacityBytes.

To view these properties need to create a variable like so;

$BEM1=Get-BEMedia –Name LTO000010

From there we can get the total and used capacity bytes:


You can also divide by GB or TB depending on your LTO tape size.



I changed about 13 lines of code (including comments) to get it working with Backup Exec 2012. It provides a good snapshot of data availability for each tape, but I am already looking at improving it further.

You will need to import-module BEMCLI first then you can run the script. You can specify tapes individually or create a variable to display all tapes in a media set.


Get-BETapeUsage –tapes LTO000010

$BEM1=Get-BEMedia – MediaSet “Keep Data for 4 Weeks”
Get-BETapeUsage –tapes $BEM1



#requires -version 2.0

Param (

#get the current window width so that our lines will be proportional
 $Width = $Host.UI.RawUI.BufferSize.Width/2

$data=Get-BEMedia -Name $Tapes

#get length of longest tape name so we can pad
 $longest=$data | select -ExpandProperty Name | sort Length | select -last 1

#group data by name
 $groups=$Data | Group-Object -Property Name

 Write-Host ("`n{0} {1}`n" -f "Backup Exec 2012 Tape Usage Report",(Get-Date)) -ForegroundColor Yellow

#iterate through each group object
 ForEach ($tape in $groups) {

    #define a collection of tapes from the group object

    #iterate through each tape in the media set
     Foreach ($drive in $drives) {
         [string]$PerFree="{0:P}" -f $FreeDividedSize

        $Used=$drive.TotalCapacityBytes - $drive.AvailableCapacityBytes
         [string]$perUsed="{0:P}" -f $UsedDividedSize

        #not currently used
         [string]$UsedGB="{0:N2}GB " -f ($Used/1GB)
         [string]$FreeGB="{0:N2}GB " -f ($drive.AvailableCapacityBytes/1GB)

        #this is the graph character

        write-host ("[{0}] {1} " -f $$longest.length),$drive.DeviceID)  -NoNewline
         write-host $freeGraph -ForegroundColor darkgreen -NoNewline
         write-host $UsedGraph -ForegroundColor red -NoNewline
         write-host (" {0} free " -f $PerFree)

        #insert a return between each drive
         write-host "`r"
     } #foreach drive
     #insert a blank line between computers if you want
     #Write-host "`n"
 } #foreach computer

About Phill McSherry
Phill McSherry has been working in the Australian IT industry for over 20 years and is the technical manager and solutions architect for managed services provider Titan Solutions -

2 Responses to Backup Exec 2012 Tape Usage Report with PowerShell

  1. Excellent. As great as your solution is, I think even more awesome is the process you took to arrive at it using cmdlets like Get-Member. Great work.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: