Powershell Script DPM ( Microsoft Azure Backup Server ) console to remove all the Cloud recovery points

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

}
}
}

}
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...