This Script allowes you to remove Recovery Points on a Microsoft Data Protection Manager 2007 Server, after XX Days.
Usage: RemoveRecoverypoints.PS1 "YourDPMserver" X
e.g.: RemoveRecoverypoints.PS1 "DPM01" 5
This will Remove All Recoverypoints, except those which are 5 max. days or less old.
param([string] $dpmname, [int32] $days )
function Usage()
{
write-host
write-host "Usage::"
write-host "RemoveRecoveryPoints.ps1 "DPMServername" Days(In int)"
write-host
}
if(("-?","-help") -contains $args[0])
{
Usage
exit 0
}
if(!$dpmname)
{
$dpmname = read-host "DPMServerName:"
}
if(!$days)
{
$days = read-host "Number of Days"
}
$pgList = Get-ProtectionGroup $dpmname
Foreach($pg in $pgList)
{
$Name = $pg.FriendlyName
Write-Host "Getting Data Source list for PG $Name..."
$dsList = Get-Datasource $pg
Foreach($ds in $dsList)
{
$Name = $ds.Name
Write-Host "Getting Recovery point list for Data-Source $Name ..."
$rpList = Get-RecoveryPoint $ds
Foreach($rp in $rpList)
{
$date = Get-Date
$datediff = $date - $rp.RepresentedPointInTime
$rpDays = $datediff.Days
Write-Host "Recovery Point is $rpDays days old "
if($rpDays -ge $days)
{
Write-Host "Removing Recovery Point older than $rpDays"
Remove-RecoveryPoint -RecoveryPoint $rp
}
}
}
}
Keine Kommentare:
Kommentar veröffentlichen