Forum Discussion

Patrick Sanouiller's avatar
Patrick Sanouiller
Brass Contributor
Jul 16, 2019

AzureFiles backup restore

Hello,
I created AzureFiles backup and want to restore So I use this script:

Select-AzureRmSubscription -SubscriptionId $AzureSubscriptionId
$Vault = Get-AzureRmRecoveryServicesVault -Name $BackupVault
Set-AzureRmRecoveryServicesVaultContext -Vault $Vault
$NamedContainer = Get-AzureRmRecoveryServicesBackupContainer -ContainerType AzureStorage –Status Registered -FriendlyName $FileShareName
$BackupItem = Get-AzureRmRecoveryServicesBackupItem –Container $NamedContainer –WorkloadType AzureFiles
$StartDate = (Get-Date).AddDays(-7)
$EndDate = Get-Date
$RecoveryPoint = Get-AzureRmRecoveryServicesBackupRecoveryPoint -Item $BackupItem -StartDate $StartDate.ToUniversalTime() -EndDate $EndDate.ToUniversalTime() 
$RestoreJob = Restore-AzureRmRecoveryServicesBackupItem -RecoveryPoint $RecoveryPoint[0] -StorageAccountName $StorageAccount -StorageAccountResourceGroupName $ResourceGroupName

But I get an error:

Get-AzureRmRecoveryServicesBackupRecoveryPoint : Cannot convert 'System.Object[]' to the type 
'Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.Models.ItemBase' required by parameter 'Item'. Specified 
method is not supported.
At line:46 char:71
+ ... -AzureRmRecoveryServicesBackupRecoveryPoint -Item $BackupItem -StartD ...
+                                                       ~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-AzureRmReco...upRecoveryPoint], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Azure.Commands.RecoveryServices.Backup.Cmdlets.GetAzureRmR
ecoveryServicesBackupRecoveryPoint

How to solve this?

Resources