Lastest Recovery Point in powershell script RRS feed

  • Question

  • Good morning all,

    I am fairly new to DPM powershell, but consider myself pretty good with powershell overall.  The issue I am having is I have written a script to query our DPM servers and retrieve the production server name, name of backup and the latest recovery point date.  Pleas see below:

    Add-PSSnapin Microsoft.DataProtectionManager.PowerShell

    $strComputer = *Name of DPM Servers*


    $red = 255
    $Green = 5287936
    $Excel = New-Object -Com Excel.Application
    $Excel.visible = $True
    $Excel = $Excel.Workbooks.Add()
    $Sheet = $Excel.WorkSheets.Item(1)
    $Sheet.Cells.Item(1,1) = “Production Server Name”
    $Sheet.Cells.Item(1,2) = “Name”
    $Sheet.Cells.Item(1,3) = “Backup Successful”
    $WorkBook = $Sheet.UsedRange
    $WorkBook.Interior.ColorIndex = 8
    $WorkBook.Font.ColorIndex = 11
    $WorkBook.Font.Bold = $True
    Connect-DPMServer $strComputer
    $intRow = 2
    $colItems = Get-ProtectionGroup $strcomputer | foreach {Get-Datasource $_} | sort Productionservername
    foreach ($objItem in $colItems) {


     if ($last -lt $date)
     $Sheet.Cells.Item($intRow,1) = $objItem.Productionservername
     $Sheet.Cells.Item($intRow,2) = $objItem.Name
     $Sheet.Cells.Item($intRow,3) = "Failed"
     $sheet.Cells.Item($intRow,3).Interior.color = $red
     $Sheet.Cells.Item($intRow,1) = $objItem.Productionservername
     $Sheet.Cells.Item($intRow,2) = $objItem.Name
     $Sheet.Cells.Item($intRow,3) = "Successful"
     $sheet.Cells.Item($intRow,3).Interior.Color = $Green

    $intRow = $intRow + 1

    Disconnect-DPMServer $strComputer

    The issue I am having is the first time I run the script against any of the servers the date that is returned is 01/01/0001.  The second time I run the script against the same server the Latest recovery point comes out fine.

    Can anyone see in the script where I have gone wrong?  Or suggest something extra that I need to do with the script to get the correct dates the first time it is run.

    Kind Regards

    Sean Buckle

    Tuesday, September 20, 2011 7:54 AM


All replies

  • I had a similar issue this morning!  I ran through a foreach loop and simply assigned $tmp = $objItem.LatestRecoveryPoint prior to running my main loop.  I also took that as an opportunity to total up some invalid or outdated recovery points for each server to add in to my report.  I tried a lot of different stuff, such as pauses, double connections, etc but nothing else worked for me.

    I do know it only happens after a Disconnect-DPMServer when you connect to a different one.  I'm betting it's a bug.

    $DPMSvrs = "SERVER1", "SERVER2"
    ForEach($svr in $DPMsvrs) {
    $pg = Get-ProtectionGroup -DPMServer $svr
    foreach ($p in $pg) {
    	$ds = Get-DataSource -ProtectionGroup $p
    	$ActionItems = 0
    	foreach ($d in $ds) {
    		if($d.State -ne "Valid") {
    			$ActionItems++ }

    		$temp = $d.LatestRecoveryPoint 

    $pg = Get-ProtectionGroup -DPMServer $svr
    foreach ($p in $pg) { 

    • Edited by Jeff Luckett Tuesday, September 20, 2011 8:11 PM
    Tuesday, September 20, 2011 8:06 PM
  • The problem is that DPM 2010 instantiates certain datasrouce properties lazily. You would think that the first time you referenced a property, it would be instantiated before returning to you, but that is apparently not the case. The first reference, causes the instantiation process of all the datasources in the collection to begin, but control is returned to you immediately. An event is raised on each datasource in the collection to signal completion of the instantiation process.  You need to hook those events and poll for completion.

    I believe this "feature" to be a bug.

    See this for details and workaround:



    Wednesday, September 21, 2011 9:17 PM