PowerShell script exchange
Post Reply
Kazz
Expert
Posts: 140
Liked: 17 times
Joined: Feb 08, 2018 3:47 am
Full Name: Kazz Beck
Contact:

VM names from a TAGs job

Post by Kazz »

Hi,

Is there a way to get a list of backed up VMs from a job that is targeting a group of VM tags or I have to get a list of tags for each job and run another powercli script against VC to get a list of VMs for each of the TAG combination I get from each job configuration?

Oleg recommended making a restAPI call against disks -> post510752.html#p510752
This would not work in one of my environments where they aren't ready to move to Enterprise Plus.

Is what I suggested above the only option I have for Veeam Enterprise?

Code: Select all


# Define CSV file path
$csvFilePath = "C:\BackupJobsReport.csv"

# Initialize an array to store job information
$jobInfo = @()

# Get all backup jobs
$backupJobs = Get-VBRJob

# Loop through each backup job
foreach ($job in $backupJobs) {
    # Get job name
    $jobName = $job.Name

    # Get job status
    $jobStatus = $job.GetLastResult()

    # Get servers included in the backup job
    $servers = $job.GetObjectsInJob()

    # Create a string with server names separated by comma
    $serversString = $servers.Name -join ", "

    # Create a custom object with job information
    $jobObject = [PSCustomObject]@{
        JobName = $jobName
        Status = $jobStatus
        ServersIncluded = $serversString
    }

    # Add the custom object to the array
    $jobInfo += $jobObject
}

# Export job information to CSV
$jobInfo | Export-Csv -Path $csvFilePath -NoTypeInformation

# Display completion message
Write-Host "Backup job information exported to $csvFilePath"

Thanks
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: VM names from a TAGs job

Post by david.domask »

Hi @Kazz, regrettably not directly at this time. The hierarchy objects (tags, datastore, folders, etc), are resolved only when accessed by the job as needed. For example, if you add a tag to the job, the only job object is the tag, and what the job will do is do a lookup for all machines with that tag and process those.

So you will need to get the tag Job Object with Get-VBRJobObject, then pass that to Find-VBRViEntity with the -Tags parameter to see what is under the tag **at the time you did the lookup**.

You can also check what the backup has processed so far with Get-VBRRestorePoint and just filter the unique item names.
David Domask | Product Management: Principal Analyst
Kazz
Expert
Posts: 140
Liked: 17 times
Joined: Feb 08, 2018 3:47 am
Full Name: Kazz Beck
Contact:

Re: VM names from a TAGs job

Post by Kazz »

Thank you David this is helpful!
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: VM names from a TAGs job

Post by david.domask »

Glad I could help! Always welcome, good luck.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests