Forum Discussion
dstamen
2 years agoPuritan
#Get Most Recent Completed Snapshot
Write-Host "Obtaining the most recent snapshot for the protection group..." -ForegroundColor Red
$MostRecentSnapshots = Get-PfaProtectionGroupSnapshots -Array $array -Name $srcprotectiongroup | Sort-Object created -Descending | Select-Object -Property name -First 2
# Check that the last snapshot has been fully replicated
$FirstSnapStatus = Get-PfaProtectionGroupSnapshotReplicationStatus -Array $array -Name $MostRecentSnapshots[0].name
# If the latest snapshot's completed property is , then it hasn't been fully replicated - the previous snapshot is good, though
if ($ -ne $FirstSnapStatus.completed) {
$MostRecentSnapshot = $MostRecentSnapshots[0].name
}
else {
$MostRecentSnapshot = $MostRecentSnapshots[1].name
}