Flag -RestoreOnlyOSDisk in powershell script doesn't work

Nermin Pezerovic 20 Reputation points


I am having issues with restoring OS disk on one of the Virtual machines. The script executes properly, but it doesn't work properly. Precisely, all disks are restored instead of restoring only OS disk. I am not sure what is the issue.

 This is the command that i am using to restore the OS disk only.

Restore-AzRecoveryServicesBackupItem -RecoveryPoint $rp[0] -StorageAccountName "accname" -StorageAccountResourceGroupName "rgname" -VaultId $Vault.Id -RestoreOnlyOSDisk 

Azure Backup
Azure Backup
An Azure backup service that provides built-in management at scale.
1,042 questions
0 comments No comments
{count} votes

Accepted answer
  1. Carlos Solís Salazar 14,866 Reputation points

    The issue you're experiencing with the Restore-AzRecoveryServicesBackupItem cmdlet, where it's restoring all disks instead of only the OS disk, could be due to various factors. Let's go through some troubleshooting steps and considerations to help resolve this issue.

    1. Verify Recovery Point Selection: Ensure that the recovery point ($rp[0]) you are selecting is indeed the correct one and corresponds to a backup of the OS disk only. If the recovery point includes other disks, they might be restored as well.
    2. Check Parameters: Double-check the parameters provided in the cmdlet, especially StorageAccountName, StorageAccountResourceGroupName, and VaultId. Any mismatches or errors here could lead to unexpected behavior.
    3. Cmdlet Syntax and Version: Ensure that the syntax of the Restore-AzRecoveryServicesBackupItem cmdlet is correct and that you're using a version of the Azure PowerShell module that supports the -RestoreOnlyOSDisk parameter. It's a good practice to keep your Azure PowerShell module up to date.
    4. Azure PowerShell Module Version: If you are using an older version of the Azure PowerShell module, consider updating it. Newer versions may have bug fixes and enhancements that could resolve your issue.
    5. Documentation and Examples: Refer to the official Azure documentation for Restore-AzRecoveryServicesBackupItem. Sometimes, the documentation contains specific examples or notes that might be relevant to your scenario.
    6. Alternative Approaches: If the script continues to not work as expected, consider alternative methods for restoring the OS disk. This might include using the Azure portal or different PowerShell cmdlets that provide more granular control over the restore process.
    7. Check for Known Issues: Look for any known issues or updates from Microsoft regarding the Restore-AzRecoveryServicesBackupItem cmdlet. Sometimes, there might be known bugs or limitations that are affecting your process.
    8. Seek Support: If you're unable to resolve the issue, consider reaching out to Microsoft support or seeking advice from the Azure community, such as forums or discussion boards. Others might have encountered and solved similar issues.

    Here is an example command structure for restoring only the OS disk. Make sure your command aligns with this structure:

    Restore-AzRecoveryServicesBackupItem -RecoveryPoint $rp[0] -StorageAccountName "<StorageAccountName>" -StorageAccountResourceGroupName "<ResourceGroupName>" -VaultId $Vault.Id -RestoreOnlyOSDisk

    Replace <StorageAccountName> and <ResourceGroupName> with your actual storage account name and resource group name.

    Accept the answer if the information helped you. This will help us and others in the community as well.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful