Expired tape as Free (Set-Tape): Do I need to remove the recovery points? RRS feed

  • Question

  • Hi,

    When I set an expired tape as free when running 

    Set-Tape -Tape $expiredTape_ -Free

    Does DPM also removes the recovery points related to that tape from disc ?

    I`m working on a script that sets free all the expired tapes in online library(s) (Yes I know DPM will mark them as free by itself when time comes but ...) , when looking at ForceFree-Tape.ps1 I see it does loop for the recovery points in the tape and removes them by :

    Remove-RecoveryPoint -RecoveryPoint $rp -ForceDeletion -Confirm:$false

    So I wonder if I also need to remove the recovery points for the expired tapes.

    Thank you .

    here is the script I`m working on:

    #Save your script (somefilename.ps1) without spaces in the name before running it
    #Run on your DPM server or specify Server name to connect to in $DPMServerName
    #Change $Exported_csv and $Transcript_Path according to your needs
    #Set $Simulate_only = $false if you want the script to make any changes
    $Exported_csv = "C:\Install\Expiredtapes-report.csv"
    $Transcript_Path = "C:\Install\Expiredtapes-report.log"
    $Simulate_only = $true
    if($Host.Version.Major -lt 3){
    		Write-Error "Requires at least PowerShell v3, your version is : $($Host.Version)" 
    		exit 1
    If ($psISE) {
        Write-Host '\*Openning console*\'
        Start-Process -FilePath 'Powershell.exe' -ArgumentList "-File $PSCommandPath"
    } else {
        Write-Host '\*In console*\'
    $sw = [Diagnostics.Stopwatch]::StartNew()
    Import-Module DataProtectionManager
    $DPMServerName = Get-Content env:computername
    if (!(Connect-DPMServer $DPMServerName)) 
        Write-Error "Failed to connect To DPM server $DPMServerName" 
        exit 1 
    Start-Transcript -Path $Transcript_Path
    $libraryList = @()
    $libraryList = Get-DPMLibrary -DPMServerName $DPMServerName | where {$_.Status -eq 'Enabled'}
    foreach ($library in $libraryList) 
        write-host Starting inventory for library $library.UserFriendlyName
        $result = Start-DPMLibraryInventory -DPMLibrary $library -DetailedInventory
    	write-host "This operation can take a long time, please be patient..."
    		while (!$result.HasCompleted)
    			$anim | % {
    			Write-Host "`b$_" -NoNewline -ForegroundColor Yellow 
    			Start-Sleep -m 50
    	write-host Inventory complete for library $library.UserFriendlyName
        $expiredTapeList = @(Get-Tape -DPMLibrary $library | ? {$_ -is [Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.LibraryManagement.ArchiveMedia] -and $_.DatasetState -eq "Recyclable"}) 
        if ($expiredTapeList.Length -gt 0) 
    		$expiredTapeList | Export-Csv -NoTypeInformation -Encoding UTF8 -Path $Exported_csv -Force -Append
            Write-Host "Marking $($expiredTapeList.Length) tape(s) as free in $($library.UserFriendlyName)." 
    		foreach ($expiredTape_ in $expiredTapeList)
                $rps = @(Get-RecoveryPoint -Tape $expiredTape_)
                if ($rps.Length -eq 0){Write-host "`r`nCould not retrieve Recovery Points for tape $($expiredTape_.Barcode) in $($expiredTape_.Location)`r`n" -ForegroundColor Red}
    			foreach ($rp in $rps)
    					Write-host "Removing recovery point created at $($rp.RepresentedPointInTime) for tape in $($expiredTape_.Location) with expiration date $($rp.RecoverySourceLocations[0].expirydate) , DatasetLifeStatus is $($expiredTape_.getDatasetLifeStatus())."
    					if($Simulate_only){Write-host "`r`nSimulation Only`r`n" -ForegroundColor Green}
    						Get-RecoveryPoint -Datasource $rp.Datasource | Out-Null
    						Remove-RecoveryPoint -RecoveryPoint $rp -ForceDeletion -Confirm:$false}
                Write-host "Setting tape in $($expiredTape_.Location) as free."
                if($Simulate_only){Write-host "`r`nSimulation Only`r`n" -ForegroundColor Green}
    				Else{Set-Tape -Tape $expiredTape_ -Free}
        } else {Write-Host "No Expired Tapes were Found in Library $($library.UserFriendlyName)" -ForegroundColor Red}
    Write-Host "`r`n Total job running time ...." $sw.Elapsed
    $a = Get-Content $Transcript_Path
    $a > $Transcript_Path

    • Edited by Alon.or Thursday, November 23, 2017 12:02 PM typo
    • Moved by jrv Thursday, November 23, 2017 12:51 PM Better forum
    Thursday, November 23, 2017 11:52 AM

All replies

  • Ask your question in the System Center forum.  It is not a scripting question but is a question about how to use SC utilities.


    Thursday, November 23, 2017 12:11 PM
  • Hi,

    I realize this is an old question, but for the benefit of anyone else stumbling onto this, here are some pointers.It's not enough to mark a tape as free for DPM to reuse it, it must also be erased.. What you are looking for is the DatasetState property.

    You can get all properties by

    $DpmLibrary = Get-DPMLibrary -DPMServerName $env:COMPUTERNAME

    Get-DPMTape -DPMLibrary $DpmLibrary | select -Property *

    so you can do if DatasetState equals Recyclable then you can pipe that to Start-DPMTapeErase

    It is subsequently marked as free and erased

    This posting is provided "AS IS" with no warranties or guarantees and confers no rights

    Friday, May 3, 2019 8:11 AM