I'm writing a Powershell script that queries the status of the latest backup of VMs as follows:
$recoveryVaultInfo = Get-AzRecoveryServicesBackupStatus -Name $vm.Name -ResourceGroupName $vm.ResourceGroupName -Type 'AzureVM'
When I run this piece of the script, I get this error:
Get-AzRecoveryServicesBackupStatus: The client 'XXX' with object id 'XXX' does not have authorization to perform action 'Microsoft.RecoveryServices/locations/backupStatus/action' over scope '/subscriptions/XXX' or the scope is invalid. If access was recently granted, please refresh your credentials.
I am a member of the LogAnalyticsReader group on the BackupVault. I am able to see the status of backups through the Backup Vault > Backup Items blade.
Why can't I do it through Powershell?