An Azure backup service that provides built-in management at scale.
Hi This is vempalli Naresh kumar Reddy from TCS , just give the vm name in $conatiner with capital letter
$container = "VMHOSTNAME"
$container = "Hostname"
#$container = Read-Host "Enter VM / Container name"
# 1. Fetch data from Resource Graph (Fixed query nesting and PowerShell variable injection)
$graphJson = az graph query -q "recoveryservicesresources | where type =~ 'microsoft.recoveryservices/vaults/backupfabrics/protectioncontainers/protecteditems' | where id contains '$container' | project rg=resourceGroup, vaultId=split(id, '/')[8]" --query "data"
$graphResult = $graphJson | ConvertFrom-Json
# 2. Safely parse variables and handle empty results
if ($graphResult) {
# If the graph returns multiple rows, select the first one to avoid breaking single-string variables
$rg = $graphResult[0].rg
$vault = $graphResult[0].vaultId
Write-Host "Success! Found Container in Vault: $vault (RG: $rg)" -ForegroundColor Green
# 3. Execute your query
az backup recoverypoint list `
--resource-group $rg `
--vault-name $vault `
--container-name $container `
--item-name $container `
--backup-management-type AzureIaasVM `
--query "[].{name:name,recoverydate:properties.recoveryPointTime,expiryTime:properties.recoveryPointProperties.expiryTime}" `
--output tsv
} else {
Write-Warning "Could not find any backup vault containing: $container"
}