Cannot validate argument on parameter 'Container'. The argument is null or empty

958 Views Asked by At

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

1

There are 1 best solutions below

5
JPBlanc On

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.