PowerShell Techguy.at

GetDPMTapeList in der Version 1.3 verfügbar

PowerShell Ich habe mein GetDPMTapeList PowerShell Script erweitert.

Ich selbst habe in den letzten Woche einige Funktionen erweitert die ich im täglichen Betrieb benötigt habe. Zusätzlich kamen von euch einige Vorschläge.

Alles in Allem ist die Version 1.3 jetzt ein echt tolles Hilfsmittel um eure Bänder im System Center Data Protection Manager zu verwalten.

Den was jetzt neu ist, ich lese ALLE Tapes aus, die dem SCDPM bekannt sind, somit habt ihr immer einen aktuellen Status für alle eure Bänder im SCDPM.

Es gibt aber noch mehr Änderungen, welche das sind zeige ich euch hier im Beitrag.

Details

Die Änderung jetzt mal im Detail

Ablaufdatum korrigiert

Ich habe einen Fehler korrigiert, der mir zuvor das falsche Ablaufdatum geliefert hat, dies wurde behoben und funktioniert nun.

Zusätzlich wird nun auch das korrekte Ablaufdatum bei bereits abgelaufenen Tapes richtig angezeigt.

Alle Bänder werden bearbeitet

Zuvor habe ich nur die Tapes ausgelesen, welche in der Bandstation waren. Jetzt hole ich mir alle Tapes die dem DPM bekannt sind, sprich die noch einen aktuellen Wiederherstellungspunkt haben.

Dazu fragen ich jede Schutzgruppe nach deren bekannten Bändern ab, auf denen sich noch ein gültiger Wiederherstellungspunkt befindet.

Dadurch habt ihr immer eine Gesamtübersicht über alle Bänder.

$Tapes=Get-ProtectionGroup | ForEach-Object {Get-Tape -ProtectionGroup $_} | Select-Object -Unique

Vorschläge was mit den Bändern passieren soll.

Ich habe mir überlegt euch aufgrund des Ablaufdatums und der Position des Bandes, auch ein paar Vorschläge zu machen, was mit dem Band passieren soll.

Aktuell gibt es 2 Vorschläge

  • “put Tape in Library”
    • Dieser Vorschlag kommt dann, wenn das Ablaufdatum (Expire) vor dem aktuellen Datum liegt und das Band außerhalb der Library ist, dann könnt ihr das Band wieder einlegen damit es für die kommende Sicherung verwendet werden kann. Hier aber nicht vergessen diese als FREI zu markieren.
  • store Tape outside”
    • Hier kommt die Variable “$ExpireRange” ins Spiel. Ist ein Band “OffSite Ready” und das Ablaufdatum aktueller als das aktuelle Datum + der Anzahl der Tage von der Variable $ExpireRange, gibt euch das Script den Hinweis das Band aus der Library zu nehmen.
    • Nochmal genauer erklärt: (Aktuelles Datum + $ExpireRange) < Ablaufdatum (Expire) = “store Tape outside”

Zusätzliche Informationen

Am Ende der CSV Datei bekommt ihr noch zusätzliche Informationen zu euren Bändern

  • Anzahl der freien Bänder, damit ihr auch genug für die nächste Sicherung habt
  • Anzahl abgelaufener Bänder aber die nicht als frei markiert wurden. Diese Bänder werden nämlich nicht für die Sicherung verwendet, so lange diese nicht als frei markiert wurden
  • Anzahl der Reinigungsbänder in der Library. Die sollte immer 1 oder mehr anzeigen, sonst kann es zu Problemen kommen.

Hier noch ein Screenshot der CSV Datei

Capture

Das Script

Hier nochmal das ganze Script in der Version 1.3 inkl. Chang Log

########################################################
# Name: GetDPMTapeList.ps1                              
# Creator: Michael Seidl aka Techguy                    
# CreationDate: 17.01.2014                              
# LastModified:15.05.2014                               
# Version: 1.3                                         
# Doc: https://www.techguy.at/tag/getdpmtapelist/
#
# Description: Read all Tapes SCDPM knows, Tapes in the Library
# and Tapes outside the Library, Gives you a List with ExpireDate, Slot, Barcode, Name
# and a recommended Action what to do with this Tape.
# At the end you get a Overview of your Tapes in the Library.
# How Many free, expired but not free and Cleaning Tapes are in the Libray
#   
# Variables
# $DPMServer = use this DPM Server, standard will be the Server on which you start the Script
# $FileName = FileName of your Output CSV
# $ExpireRange = a Number of Days, if a Tape in your Library has Expire Date more than this Days and is Offsite Ready, Action will be to store the Tape Outside the Library
# $FilePath = Where to store the CSV File
#
# Version 1.3 - FIX: small fix with wrong ExpireDates
#               CHANGE: Get all Tapes they are known by SCDPM and list if Offsite or note with expire Date
#               CHANGE: If Slot ist 0, Tape is Outside
#               CHANGE: Gives you an Advice what to do with the Tapes, put it back in or store the Tape outside
#               CHANGE: writes additional Informations at the End, How many free, expired and Cleaner Tapes
#
# Version 1.2 - CHANGE: Input of Tapes to an Array
#               CHANGE: Sort Ouput by Expire Date
# 
# Version 1.1 - FIX: Format the Output ExpireDate
#             - CHANGE: DPMServer takes local Computername
#             - CHANGE: File will be saved at Script Location
#
# Version 1.0 - RTM
########################################################
#
# www.techguy.at                                        
# www.facebook.com/TechguyAT                            
# www.twitter.com/TechguyAT                             
# michael@techguy.at 
########################################################

#Import Modules
Import-Module dataprotectionmanager

#Variables
$DPMServer="$env:COMPUTERNAME"
$FileName="DPMTapeList.csv"
$ExpireRange="30"
$LogPath="D:\_BaseIT"

#Settings
$Library=Get-DPMLibrary -DPMServerName $DPMServer
$Tapes=Get-ProtectionGroup | ForEach-Object {Get-Tape -ProtectionGroup $_} | Select-Object -Unique
$File=$LogPath+"\"+$FileName
$Array=@()
$OutsideDate=(Get-Date).AddDays($ExpireRange)

#Delete File and create new one
if (Test-Path $File) {Remove-Item $File}
"Expire;Name;Slot;Barcode,Action"| Out-File -FilePath $File -Append

#Magic
foreach ($Tape in $Tapes) {
    $Lower=$False
    $Action = ""
    $RPs=Get-RecoveryPoint -Tape $Tape
    $ExpDate = $RPs[0].recoverysourcelocations[0].expirydate
    foreach ($RP in $RPs) {
        if ($ExpDate -lt $RP.recoverysourcelocations[0].expirydate) {
            $ExpDate = $RP.recoverysourcelocations[0].expirydate  
        } 
    }
    if ($ExpDate.Date -lt (Get-Date)) {$Lower=$True} 
    if ($Tape.Location.Id -eq 0) {$Slot = "Outside"} else {$Slot = $Tape.Location.Id}
    if ($Slot -eq "Outside" -and $Lower -eq $true) {$Action = "put Tape in Library"} 
    if ($Slot -ne "Outside" -and $ExpDate.Date -gt $OutsideDate -and $Tape.IsOffsiteReady -eq $True ) {$Action = "store Tape outside"} 
    $obj = New-Object -TypeName PSObject
    $obj | Add-Member Noteproperty  -Name Expire -value $ExpDate.Date
    $obj | Add-Member Noteproperty -Name Tape -value $Tape.DisplayString
    $obj | Add-Member Noteproperty -Name Slot -value $Slot
    $obj | Add-Member Noteproperty -Name Barcode -value $Tape.Barcode.Value
    $obj | Add-Member Noteproperty -Name Action -value $Action
    $Array+=$obj
}

$Array | Sort expire -Verbose | Export-Csv -Path $File -Encoding ascii -NoTypeInformation

#Additional Informations
$FreeTapes=(Get-Tape -DPMLibrary $Library | where {$_.MediaPoolType -eq "Free"}).count 
$NonFreeTapes=(Get-Tape -DPMLibrary $Library | where {$_.DatasetState -eq "Recyclable"}).count
$CleanerTapes=(Get-Tape -DPMLibrary $Library | where {$_.Type -eq "CleanerMedia"}).count

add-Content -Path  $File -Value  ""
add-Content -Path  $File -Value  ""
add-Content -Path  $File -Value  ""
add-Content -Path  $File -Value  $FreeTapes" Tapes a free for next Backup"
add-Content -Path  $File -Value  $NonFreeTapes" Tapes are expired but not marked as free"
add-Content -Path  $File -Value  $CleanerTapes" Cleaning Tapes are in Library"

Den Download zum aktuellen Script findet ihr in der TechNet Gallery: http://gallery.technet.microsoft.com/DPM-Tape-List-with-1f9fc697

Bitte nehmt euch die Zeit und bewertet meine Downloads in der TechNet Gallery, würde mich sehr freuen.

Hier findet ihr alle meine Download in der TechNet Gallery: http://gallery.technet.microsoft.com/site/search?f%5B0%5D.Type=Tag&f%5B0%5D.Value=TechguyAT&f%5B0%5D.Text=TechguyAT

Was wünscht ihr euch noch von diesem Script oder könnt ihr es überhaupt benötigen?

Michael Seidl aka Techguy

12 thoughts on “GetDPMTapeList in der Version 1.3 verfügbar”

  1. hallo,

    hab das Problem das ich von einer externen DPM 200 Bänder einlesen muss. und danach eine Liste erstellen muss welche Inhalte auf den Bänder sind.

    hab auch fleissig alle Bänder eingelegt und eingelesen, finde auch alle recoverypoints und Daten im Recovery Reiter unter External DPM Tapes.

    aber wie bekomme ich alle Äaten zb als CSV?

    danke für die Hilfe

  2. Hallo,

    probiere mal dir die Recoverypoints per PowerShell zu holen, dort findest du sicherlich ein Property wo dieser RP liegt, das sollte was von Tape(imported) stehen.

  3. Dear Michael,

    This is an excellent script. Would it be possible to also add 1 more column for “Backup time” of the latest backup done on that tape?

  4. Martin Podgorsek

    Hi. Your script does not return us the list of tapes. The csv file only contains 0 Tapes a free for next Backup, 0 Tapes are expired but not marked as free, 1 Cleaning Tapes are in Library. We do not have any Protection Group created, but we have many Inactive Protections with tapes availabe. We found the list of tapes in MM_Media sql table, but no expirations dates. Can you help us?

  5. hi,
    the Script has to be changed a little bit to collect Informations from inactive Protections Groups.
    At the moment we only get Tape from active Protection Groups.

  6. Thanks for the script, it’s very handy!

    One note, line 54 is missing $DPMServer when it runs Get-ProtectionGroup, this caused it to prompt for the server when I run it.

    Should be:
    $Tapes=Get-ProtectionGroup $DPMServer | ForEach-Object {Get-Tape -ProtectionGroup $_} | Select-Object -Unique

    You did all the heavy lifting though 🙂

  7. Hi Michael,
    I’m getting the error below any idea?
    Thanks in advance.

    At C:\DPM\GetDPMTapeList\GetDPMTapeList.ps1:65 char:36
    + “Expire;Name;Slot;Barcode,Action”| Out-File -FilePath $File -Append
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OpenError: (:) [Out-File], IOException
    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand

    Regards,

    Peter

  8. enrico.borck@arcor.de

    Hallo,

    erstmal vielen dank für das geile Script, welches ich aber leider nciht wirklich anwenden kann, da ich folgende Fehlermedlung erhalte beim Ausführen:

    Es ist nicht möglich, einen Index auf ein NULL-Array anzuwenden.
    + $ExpDate = $RPs[0].recoverysourcelocations[0].expirydate
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

    Einen Tip was dass ein könnte ?

    LG

    Enrico

Leave a Comment

Your email address will not be published. Required fields are marked *

*