0

I’m working on triggering an on-demand backup for my machines. But while running ps script it shows the below error. "Cannot validate argument on parameter 'Container'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again".

$vault = Get-AzRecoveryServicesVault -ResourceGroupName "xxxx" -Name "xxxx"
Set-AzRecoveryServicesVaultContext -Vault $vault
$backupcontainer = Get-AzRecoveryServicesBackupContainer -ContainerType "AzureVM" -FriendlyName "testvm"
$item = Get-AzRecoveryServicesBackupItem -Container $backupcontainer -WorkloadType "AzureVM"

the above code was working fine couple of months ago. I have tried using different vm names in -FriendlyName but no luck.

Please suggest

JPBlanc
  • 70,406
  • 17
  • 130
  • 175
Aditya c
  • 3
  • 1
  • 4
  • The above script should add existing vm to the recovery vault? or it will only trigger backup for existing vms? – Aditya c Feb 07 '22 at 18:00

1 Answers1

0

The PowerShell response is that Get-AzRecoveryServicesBackupContainer do not respond a valid container object but $null. Why I don't know.

But you should test the return values of the CmdLets you call before using them in other CmdLets.

JPBlanc
  • 70,406
  • 17
  • 130
  • 175