Wednesday, October 7, 2009

Tape library inventory using Powershell

The command to start a fast or detailed inventory using Powershell is not to difficult, the trick is to get the correct name for the tape library.
In the example below we use an additional Powershell command to read the Library name in to a variable.  

First we need to list all tape libraries attached to the DPM server. When you have a Tape library attached, you might see the drive listed as well. Note the order the tape libraries are listed.
(replace dpm01 with the name of your DPM server)

PS > get-dpmlibrary -DPMServerName dpm01

Name                                     Drives                   Slots          I/E ports
----                                     ------                   -----               ---------
Stand-alone Drive: I...                       1                    0                 0          #0
Library: Library1                             2                      23                1          #1

Now we read the library details in to the variable $DPMlib
(replace dpm01 with the name of your DPM server)

$dpmlib = get-dpmlibrary -DPMServerName dpm01

Using the information collected with the first command we now can start the inventory. The number added to the $DPMlib variable is the order number in which the library is listed, start counting with 0. In this example, the number 1.

Fast inventory:

PS > Start-DPMLibraryInventory -DpmLibrary $dpmlib[1]

JobCategory                        Status                             HasCompleted
-----------                             ------                                  ------------
FastInventory                      Scheduled                            False

Detailed inventory:

PS > Start-DPMLibraryInventory -DetailedInventory -DpmLibrary $dpmlib[1]

JobCategory                        Status                                  HasCompleted
-----------                             ------                                  ------------
DetailedInventory                Scheduled                               False

When you use it in a script it will look like this

$dpmlib = get-dpmlibrary -DPMServerName dpm01
Start-DPMLibraryInventory -DpmLibrary $dpmlib[1]


  1. Great in DPM 2007, doesn't work in DPM 2010 :(

  2. I appreciate your post, thanks for sharing the post, i would like to hear more about this in future