Tuesday, January 28, 2014

DPM–How to Mark Tape as Free

Sometimes we hit the issue of having difficulty of marking the Tape as Free in the DPM Library.    The tape is label as “Unknown” at times and can’t mark it as Free in the DPM Console. Then I scout around and found that I need to do this in PowerShell.

Copy the following Script (in green) into a Notepad and place into a directory in the DPM server.  Rename it as a powershell extention.  I name it as ForceFree.ps1.

param ([string] $DPMServerName, [string] $LibraryName, [string[]] $TapeLocationList)

if(("-?","-help") -contains $args[0])
{
Write-Host "Usage: ForceFree-Tape.ps1 [[-DPMServerName] <Name of the DPM server>] [-LibraryName] <Name of the library> [-TapeLocationList] <Array of tape locations>"
Write-Host "Example: Force-FreeTape.ps1 -LibraryName "My library" -TapeLocationList Slot-1, Slot-7"
exit 0
}

if (!$DPMServerName)
{
$DPMServerName = Read-Host "DPM server name: "

if (!$DPMServerName)
{
Write-Error "Dpm server name not specified."
exit 1
}
}

if (!$LibraryName)
{
$LibraryName = Read-Host "Library name: "

if (!$LibraryName)
{
Write-Error "Library name not specified."
exit 1
}
}

if (!$TapeLocationList)
{
$TapeLocationList = Read-Host "Tape location: "

if (!$TapeLocationList)
{
Write-Error "Tape location not specified."
exit 1
}
}

if (!(Connect-DPMServer $DPMServerName))
{
Write-Error "Failed to connect To DPM server $DPMServerName"
exit 1
}

$library = Get-DPMLibrary $DPMServerName | where {$_.UserFriendlyName -eq $LibraryName}

if (!$library)
{
Write-Error "Failed to find library with user friendly name $LibraryName"
exit 1
}

foreach ($media in @(Get-Tape -DPMLibrary $library))
{
if ($TapeLocationList -contains $media.Location)
{
if ($media -is [Microsoft.Internal.EnterpriseStorage.Dls.UI.ObjectModel.LibraryManagement.ArchiveMedia])
{
foreach ($rp in @(Get-RecoveryPoint -Tape $media))
{
Get-RecoveryPoint -Datasource $rp.Datasource | Out-Null

Write-Verbose "Removing recovery point created at $($rp.RepresentedPointInTime) for tape in $($media.Location)."
Remove-RecoveryPoint -RecoveryPoint $rp -ForceDeletion -Confirm:$false
}

Write-Verbose "Setting tape in $($media.Location) as free."
Set-Tape -Tape $media -Free
}
else
{
Write-Error "The tape in $($media.Location) is a cleaner tape."
}
}
}

Double click on the DPM PowerShell in the DPM Server to launch the PowerShell


Type the powershell script that you’ve name it.  My example is ForceFree.ps1, therefore I keyed in as .\ForceFree.ps1


Then I keyed in the DPM Server Name, the Library Name and which slot of tape I want to Free it.


image


Once it’s done, then the tape can be re-use it.  Just go through the DPM Library and Erase it from the DPM Console.


Hope this helps. This article was simplified from TechNet.


keywords : DPM 2010, DPM 2012, DPM, free tape, mark tape as free, tape label as unknown, tape cannot erase


No comments:

Post a Comment