none
Recover VHD to folder location RRS feed

  • Question

  • Hello, I'm trying to script the recovery of some .VHD's.  I've managed to get this working by importing to an alternate HyperV Server like this:

    $rop = New-RecoveryOption -HyperVDatasource -TargetServer $targetServerName -RecoveryLocation AlternateHyperVServer -RecoveryType Recover -TargetLocation $restorePath

    Recover-recoverableitem -RecoverableItem $rp[0] -recoveryoption $rop

     

    However, I'd like to get it working using something like this so that I can just dump the .VHD without having the machine created in Hyper-V:

    $rop = New-RecoveryOption -targetserver $targetserver -recoverylocation copytofolder -FileSystem -alternatelocation $restorepath -recoverytype restore -OverwriteType Overwrite

    Recover-recoverableitem -RecoverableItem $rp[0] -recoveryoption $rop

     

    Here's the full code that I've borrowed from another poster:

    $dpmname = "DPMServer";
    $psname = "HyperVHost";
    $dsname = "VMName";
    $pgname = "ProtectionGroupName";
    $targetServerName = "Target Hyper-V hostName";


    $restorePath = "E:\VM"
    $rpIndex = 0 #0 is the latest.

    $pg = get-protectionGroup -DPMServerName $dpmname | where {$_.friendlyname -eq $pgname}

    $ds = @(get-datasource -protectiongroup $pg | where {$_.name.ToLower().EndsWith($dsname)})
     
    $rp = @(get-recoverypoint -datasource $ds[0] | sort -Property RepresentedPointInTime -Descending)

    #Original: $rop = New-RecoveryOption -HyperVDatasource -TargetServer $targetServerName -RecoveryLocation AlternateHyperVServer -RecoveryType Recover -TargetLocation $restorePath
    $rop = New-RecoveryOption -targetserver $targetServerName -recoverylocation copytofolder -FileSystem -alternatelocation $restorePath -recoverytype restore -OverwriteType Overwrite

     
    Recover-recoverableitem -RecoverableItem $rp[0] -recoveryoption $rop

    However, I get an error every time I run this and I don't know where I've gone wrong.  I can do it line-by-line and it all works to the last line and I can get output for each of the variables.  Any ideas?

     

    Thanks.

     

     

    Tuesday, May 10, 2011 11:10 PM