Restore more than 250 files RRS feed

  • Question

  • Hi All,

    we had a virus that corrupt all our PDF files.

    I'm not very familiar with power shell.

    I search the Internet and found a couple of pages that helped me building my script.

    Everything seems to work fine until I realize that New-SearchOption returns a maximum of 250 results.  I need to restore thousands of pdf files.

    Here is the code I ended with.

    $pg = get-protectiongroup –dpmservername SERVERNAME
    $ds = get-datasource –protectiongroup $pg[PG_INDEX]
    $rp = get-recoverypoint –datasource $ds
    $datefrom = Get-Date "START DATE"
    $dateto = Get-Date "END DATE"
    $so = New-SearchOption -SearchString "*.pdf" -SearchDetail filesfolders -SearchType endsWith -Recursive -Location "LOCATION" -FromRecoveryPoint $datefrom -ToRecoveryPoint $dateto
    $ro = New-RecoveryOption -TargetServer SERVER_NAME -RecoveryLocation copytofolder -FileSystem -AlternateLocation "ALTERNATE_LOCATION" -OverwriteType NoOverwrite -RecoveryType Restore
    $recoveryJob = Recover-RecoverableItem -RecoverableItem $gr -RecoveryOption $ro
    while (! $recoveryJob.hasCompleted )
        # Show a progress bar
        Write-Host "." -NoNewLine
        Start-Sleep 1
    if($recoveryJob.Status -ne "Succeeded")
        Write-Host "Recovery failed" -ForeGroundColor Red
        Write-Host "Recovery successful" -ForeGroundColor Green

    please help!!



    Saturday, March 21, 2015 2:43 PM

All replies

  • Hi Mathieu,

    I don't know if you can inrease the maximum result value but I guess you could get each file at the time with something like this:

    Get-ChildItem "LOCATION" -Recurse -File -Filter *.pdf | ForEach-Object { New-SearchOption $_ }

    Monday, March 23, 2015 10:57 PM
  • Hi Mathieu,

    Narrow down the search range using dates\time

    $datefrom = Get-Date "START DATE"
    = Get-Date "END DATE"

    Run a loop to search across various dates.

    Or you can also modify the -SearchString "A*.pdf" to loop alphabetically A-Z. to reduce the results under 250.



    Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

    Thursday, April 30, 2015 7:26 AM
  • Hi,

    Thanks for your reply.

    What I did finally is a folder by folder restore.  I went on the server and make a list of all infected folders.  Then in my powershell script I looped on the list of folder (without the recursive flag) and did a restore for each folder...  It took hours, but it worked.

    • Proposed as answer by Satyajit321 Monday, May 4, 2015 8:56 AM
    Thursday, April 30, 2015 1:05 PM
  • Hi Mathieu,

    I'm glad to hear that your problem was finally resolved!

    If you find mine or Satyajit replies as answers or helpful please remeber to mark them as so!.

    Take care!


    Monday, May 4, 2015 9:05 AM