none
Powershell script to automate test restore RRS feed

  • Question

  • $Pg = Get-DPMProtectionGroup | Out-GridView -OutputMode Single

    $Ds = Get-DPMDatasource -ProtectionGroup $Pg[0] | Out-GridView -OutputMode Single

    $RecoveryObject = Get-DPMRecoverypoint -Datasource $Ds[0] | Sort -Property RepresentedPointInTime -Descending | Out-GridView -OutputMode Single

    $RecoveryOption = New-DPMRecoveryOption -HyperVDatasource -TargetServer "HyperVHost.DOMAIN.local" -RecoveryType Recover -TargetLocation “C:\Restores” -RecoveryLocation AlternateHyperVServer

    Restore-DPMRecoverableItem -RecoverableItem $RecoveryObject -RecoveryOption $RecoveryOption

    Hi, I hope someone can advise.

    Above is my script, which I am trying to develop to run test restores more speedily. The Restore Wizard on all my servers takes ages to run, so I’m trying to script it. When the script runs it prompts the user for a Protection Group, then it prompts for the Data Source within the selected PG. Finally, it prompts for the required Protection Point.

    When the script runs, it restores the VM to the Hyper-V Host specified, and attaches the VM to the Host, in a stopped state.

    This is not what I want to happen. I wish to restore the vhd file to a location, without attaching it to the Hyper-V Host. My problem is probably the –RecoveryType parameter which I believe should be either Recovery or Restore, but it could also be the RecoveryLocation parameter, but when I try the CopyToFolder option, I get a message saying the recovery point location is invalid (it isn’t!). If I specify a different RecoveryLocation (C:\Restores), I get the same error.

    New-DPMRecoveryOption : The recovery point location that you have passed is invalid. Please try again with a different value. (ID: 31050)

    I have 2 things I wish to achieve initially:

    • Restore the VHD file to the specified location
    • Amend the Script to that I can have an additional section that determines the -TargetServer and the –TargetLocation based on the DPM Server that runs the script.

    We have several DPM servers, all in different locations and all with different drives available to the recovery process. I would hope to achieve something like the SQL Case select statements that say if DPMServerA then TargetLocation is LocationA, if DPMServerB then TargetLocation in LocationB, etc. This would allow me to run the same script on all of the DPM Servers, and automate the recovery process target selection.

    The final thing I would like to achieve, once the 2 points above are completed is that I wish to run the script in the same way to recovery an SQL Database to a network folder (not attach it to an SQL Server) – this would allow me to restore SQL Databases under test conditions. I need to amend the script in such a way that I get prompted either SQL/Hyper-V and my selection amends the $RecoveryOption line. But I cannot work out how to do this.

    I’ve had a good look at https://technet.microsoft.com/en-us/library/hh881592(v=sc.20).aspx and I’m sure the answers are in there, but I can’t work it out, unfortunately

    Pease can someone advise on how to complete these aims?

    Many Thanks in advance.

    Regards

    John


    Regards, John

    Thursday, August 6, 2015 1:48 PM

Answers

All replies

  • hi,

    try to change -RecoveryType Restore at the $RecoveryOption = New-DPMRecoveryOption -HyperVDatasource -TargetServer "HyperVHost.DOMAIN.local" -RecoveryType Recover -TargetLocation “C:\Restores” -RecoveryLocation AlternateHyperVServer


    Have a nice day !!!
    DPM 2012 R2: Remove Recovery Points
    DPM blog
    System Center
    Hyper-V


    Thursday, August 4, 2016 1:16 PM
    Moderator
  • Hello Eugene,

    Many Thanks for your email - the change you suggested is what was needed and the script now seems to work as I wished it to work. Now all I need to do is get it to automate the target server details based on the DPM Server name, so that the script runs as expected on each DPM server and automatically restores to the correct location for that Server.

    Many Thanks

    regards

    John


    Regards, John

    Wednesday, August 10, 2016 3:17 PM