Systems Center Data Protection Manager 2010–List the Contents and Status of your Tapes

Caught this one in Twitter today.  A fellow needed to know of a way to list the status of all the tapes on all his DPM Servers.

It makes sense.  You need to easily report on what tapes can be pulled, where the data is, which ones are expired.

I’m also not going to be done in just one posting.  There’s a lot here but I’ll list the important Cmdlets that pull the data.  The rest is a matter of Scripting it into a report

Our first task is pull all the Tape libraries together.  That’s done by using a

GET-DPMLibrary –DPMServerName ‘NameOfADPMServer’

You can then pipe that list of tape  libraries into

GET-TAPE

which will actually pull a list of all the tapes out for you as well.  Now for the tricky part.  Finding what’s on the tapes.   You have to pipe THAT into a

GET-RECOVERYPOINT

So a simple one liner will dump all the recovery points on TAPE like so

GET-DPMLibrary –DPMServerName ‘NameOfADPMServer’ | GET-TAPE | GET-RECOVERYPOINT

Ok neat, that worked.   But it’s not very useful is it?   I mean we need to know what TAPE each point is on and it would be a great thing to know which server has that tape.   Be even BETTER if we knew the library.

Well that’s doable.   We just script it.   Instead of just piping in and pooping out what we say (*sorry, I couldn’t resist…. no wait… yes I could…*) We could pull out the blocks of information and break them down.

So first …. let’s store away that list of libraries

$TAPELIBRARIES=GET-DPMLibrary –DPMServerName ‘NameOfADPMServer’

Now we can loop through each library and EXAMINE the tapes and show the contents

Foreach ($TAPELibrary in $TAPELIBRARIES) {

$TAPELIST=$TAPELibrary | GET-TAPE

Then we’ll step through the tapes and show their contents

Foreach ( $TAPE in $TAPELIST ) {

$RP=$TAPE | GET-RECOVERYPOINT

Then you step through each Recovery point for individual details

Foreach ($point in $RP) {

So how is this any better?   At this point you now have data that you can’t easily pull out of the pipe.  As you “PIPE” information into each Cmdlet, each Cmdlet is only going to pass along information IT is supposed to produce. So in writing a script we can now pull out specific information and build a report from it.  Or simply build it into CSV file.  There is certain Key useful information from each part we could use for a report.

 

From $TAPELibraries

UserFriendlyName – Nice name give to describe a particular tape unit

MachineName – We should be able to say which server any of these tapes and drives are on

 

From $TAPELlist

Barcode – for Easy Identification when removing from a Library

CreationDate – Good to know how old it is

DatasetState – Current or ready for Recycling?

DataWrittenDisplayString – How much is sitting on that tape?  How many Gigs/Megs?

IsOffsiteReady – Can we send this for offsite storage?

Location – What slot is the tape sitting it?

 

From $RP (our Recovery Points)

UserFriendlyName – Very descriptive name of what is on there

Size – How many Bytes is that sucker eating up

 

So what can we do with this?  Build a simple onscreen report like so.   Get the data from each line and spit out to the console (Hey, It’s late and I wanna go home, so you can play with it your own way) Winking smile

$TAPELIBRARIES=GET-DPMLibrary –DPMServerName ‘NameOfADPMServer’

$FILENAME=’C:PowershellDPMTapes.csv’

NEW-ITEM –path $FILENAME –itemtype File –force

$HEADER=’TapeLibrary,ComputerName,TapeLocation,TapeState,Barcode,CreationDate,RecoveryPointName,Size’

ADD-CONTENT –path $FILENAME –value $HEADER

Foreach ($TAPELibrary in $TAPELIBRARIES) {

     $TLUFN=$TAPELibrary.UserFriendlyName
     $TLMN=$TAPELibrary.Machinename

     $TAPELIST=$TAPELibrary | GET-TAPE

         Foreach ( $TAPE in $TAPELIST ) {

         $TapeLocation=$Tape.Location
         $TapeState=$Tape.DataSetState
         $TapeBarcode=$Tape.Barcode
         $TapeDate=$Tape.CreationDate

              $RP=$TAPE | GET-RECOVERYPOINT

              Foreach ($point in $RP) {

               $RPUFN=$Point.UserFriendlyName
               $RPSize=$Point.Size

                $OUTPUT=$TLUFN+’,’+$TLMN+’,’+$Tapelocation+’,’+$TapeState+’,’+$TapeBarcode+’,’+$Tapedate+’,’+$RPUFN+’,’+$RPSize

                ADD-CONTENT –path $FILENAME –value $OUTPUT

                }

       }

}

Yes…. I agree the script is horribly written and even worse for formatting Smile Yes we should have filtered too and made it nicer.

But now that you have this, you can tweak it away.  Add your own information.  Since it’s a CSV file, this can be played with in Excel, or just use a SEND-MAILMESSAGE after mining.

The Power is yours and the Power of Shell is in YOU

Sean
the Energized Tech

Leave a Reply