Disk backup history-"Subscription ids have to be valid GUIDs. Given:

asked 2022-06-24T18:07:33.847+00:00
Siva 626 Reputation points

Hi Team,

I am getting the below error while run the below script, please assist on this.

$Subscriptions=@('Subscriptionname')
$ErrorActionPreference = 'stop'
foreach ($sub in $Subscriptions)
{
Get-AzSubscription -SubscriptionName $sub | Set-AzContext |fl
$TestBkpVault = Get-AzDataProtectionBackupVault -VaultName "testvault" -ResourceGroupName "Backuprg"
$TestBKPVault | fl
$endtime = Get-Date
$starttime = $endtime.AddHours(-20)
$job = Search-AzDataProtectionJobInAzGraph -Subscription $sub -ResourceGroup "Backuprg" -Vault $TestBkpVault.Name -DatasourceType AzureDisk -Operation ScheduledBackup -StartTime $starttime
$job
}

Error:
Az.ResourceGraph\Search-AzGraph : {
"error": {
"code": "BadRequest",
"message": "Please provide below info when asking for support: timestamp = 2022-06-24T17:58:53.0334899Z, correlationId =.",
"details": [
{
"code": "SubscriptionsContainInvalidGuids",
"message": "Subscription ids have to be valid GUIDs. Given: 'Subscriptionname."
}
]
}
}
At C:\Program Files\WindowsPowerShell\Modules\Az.DataProtection\0.4.0\custom\Cmdlets\Backupcenter\Search-AzDataProtectionJobInAzGraph.ps1:80 char:27

  • ... $argJobResponse = Az.ResourceGraph\Search-AzGraph @PSBoundParameters
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : CloseError: (:) [Search-AzGraph], ErrorResponseException
  • FullyQualifiedErrorId : BadRequest,Microsoft.Azure.Commands.ResourceGraph.Cmdlets.SearchAzureRmGraph
Azure Backup
Azure Backup
An Azure backup service that provides built-in management at scale.
774 questions
No comments
{count} votes

Accepted answer
  1. answered 2022-06-27T12:05:09.17+00:00
    Swathi Dhanwada 9,381 Reputation points Microsoft Employee

    @Siva I understand that you are trying to retrieve disk backup history. I have done small modifications to your existing code. The reason you were prompted with mentioned error is because the command "Search-AzDataProtectionJobInAzGraph" accepts the subscription Id instead of subscription name. The value you are passing is subscription name.

    $Subscriptions=@('Subscriptionname')  
    $ErrorActionPreference = 'stop'  
    foreach ($sub in $Subscriptions)  
    {  
    $subname = Get-AzSubscription -SubscriptionName $sub   
    Set-AzContext -Subscription $subname.Id  
    $TestBkpVault = Get-AzDataProtectionBackupVault -VaultName "testvault" -ResourceGroupName "Backuprg"  
    $TestBKPVault | fl  
    $endtime = Get-Date  
    $starttime = $endtime.AddHours(-20)  
    $job = Search-AzDataProtectionJobInAzGraph -Subscription $subname.Id -ResourceGroup "Backuprg" -Vault $TestBkpVault.Name -DatasourceType AzureDisk -Operation ScheduledBackup -StartTime $starttime  
    $job  
    }  
    

    If the above solution has helped , kindly "Accept as answer" or "upvote", so that it would be beneficial for other customers who are looking for similar solution.


0 additional answers

Sort by: Most helpful