PowerShell script exchange
albertwt
Expert
Posts: 724
Liked: 25 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Powershell to list Backup Job name, VMs and its retention?

Post by albertwt »

Hi Experts,

Can anyone here please share the PowerShell script to list Veeam Backup Job name, its VM content and the Retention policy for each backup job?
Any other methods are welcome.

Thank you in advance.
--
/* Veeam software enthusiast user & supporter ! */

Lucas_H
Influencer
Posts: 17
Liked: 4 times
Joined: Nov 16, 2018 3:14 pm
Full Name: Lucas HELLMANN
Location: Lyon, FRANCE
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by Lucas_H » 1 person likes this post

Hello,

I would have done something like this :

Code: Select all

asnp VeeamPSSNapin
$jobs = Get-VBRJob | ?{$_.JobType -eq "Backup"}
Foreach ($job in $Jobs) {   
    $Objs = $job.GetObjectsInJob()
    $VMList = @()
    Foreach ($obj in $Objs) {
        $VMList=$VMList+$obj.Name
    }
    $Option = $Job.BackupStorageOptions.RetainCycles
    $JobName = $Job.Name
    Write-Host $JobName "`nRetention period : " $Option "`nVM List : " $VMList
}
it may not be the best script but It will do the job.

Cheers,
Lucas.

albertwt
Expert
Posts: 724
Liked: 25 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by albertwt »

Many thanks Lucas,

Would it be possible to list the size of the backup with the script below and the Backup Repository it is located?

Code: Select all

Get-VBRJob | ?{$_.JobType -eq "Backup"} | %{
	$JobName = $_.Name
	$_ | Get-VBRJobObject | ?{$_.Object.Type -eq "VM"} | Select @{ L="Job"; E={$JobName}}, Name, @{ L="Size"; E={$_.ApproxSizeString}} | Sort -Property Job, Name
}
--
/* Veeam software enthusiast user & supporter ! */

Lucas_H
Influencer
Posts: 17
Liked: 4 times
Joined: Nov 16, 2018 3:14 pm
Full Name: Lucas HELLMANN
Location: Lyon, FRANCE
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by Lucas_H »

Hello,

Did some modification with the script I posted and what you posted :

Code: Select all

asnp VeeamPSSnapin
Get-VBRJob | ?{$_.JobType -eq "Backup"} | %{
    
    $job = $_
    $JobName = $_.Name
    $Backup = Get-VBRBackup -Name $JobName
    $lastsession = $job.FindLastSession()
    $Session = $job.FindLastSession()
    foreach($tasksession in $lastsession.GetTaskSessions()) {
    $PointsOnDisk = (get-vbrbackup -Name $job.Name | Get-VBRRestorePoint -Name $tasksession.Name | Measure-Object).Count 
    $BackupTotalSize = [math]::round($Session.Info.Progress.TotalUsedSize/1Gb,2)
    $BackupSize = [math]::round($Session.Info.BackedUpSize/1Gb,2)
    $RepositoryPath = $Backup.Info.DirPath.ToString()
    $LastBackupStart = $Session.CreationTime
    $LastResult = $job.GetLastResult()
    }
	$_ | Get-VBRJobObject | ?{$_.Object.Type -eq "VM"} | Select @{ L="Job"; E={$JobName}}, Name, @{ L="Size"; E={$_.ApproxSizeString}}, @{ L="PointsOnDisk"; E={$PointsOnDisk}}, @{ L="LastResult"; E={$LastResult}}, @{ L="LastBackupStart"; E={$LastBackupStart}}, @{ L="LastBackupTotalSize"; E={$BackupTotalSize}}, @{ L="LastBackupSize"; E={$BackupSize}}, @{ L="RepositoryPath"; E={$RepositoryPath}} | Sort -Property Job, Name
}
This script check for each VM in a Backup Job :
  • The VMSize
  • The number of restore points available on disk
  • The last backup result and the start Time
  • The last backup : total size and data copied on disk
  • And the repository path (I'm not sure if this is what you wanted ?)
To note : It is pretty slow (around 10 seconds per Vm).
I didn't look much further to optimize it, I think the slow point is when it checks for the repository path, the two foreach doesn't help much either as I'm far from being a powershell expert.

Tell me if this works for you :)

Cheers,
Lucas

albertwt
Expert
Posts: 724
Liked: 25 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by albertwt »

Lucas,

Thank you for your help in this matter, somehow it is returning the below error instead of any result?
You cannot call a method on a null-valued expression.
At line:15 char:9
+ $RepositoryPath = $Backup.Info.DirPath.ToString()
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Which refers to this line:
$RepositoryPath = $Backup.Info.DirPath.ToString()
--
/* Veeam software enthusiast user & supporter ! */

Lucas_H
Influencer
Posts: 17
Liked: 4 times
Joined: Nov 16, 2018 3:14 pm
Full Name: Lucas HELLMANN
Location: Lyon, FRANCE
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by Lucas_H »

Hello,

Yes I had this problem on some backup too, I had this solved but I didn't post the up to date one.
This is because you may have changed the job name at some point but the backup name didn't change with it.
In my case : I had job like : Job-CLIENT before and now I have Job-CLIENT-HPV or (VMW depending on the infrastucture). So If you are in a similar situation, the script below might work.

To correct it I added a little if loop that check if the Backup here is null : $Backup = Get-VBRBackup -Name $JobName
If it is empty, I know that in my case I will have to crop the end to get the right backup corresponding to the job.
Here the code to add just after $Backup = Get-VBRBackup -Name $JobName

Code: Select all

if ($Backup -eq $null) {
        $BackupName = $JobName.Remove(7,4) #The number are for my case, you might changed it 
        $Backup = Get-VBRBackup -Name $BackupName    }
 else {}
Another solution would be to rename the Job to the correct Backup name, it should work too.

Cheers,
Lucas

acepero
Novice
Posts: 7
Liked: never
Joined: Feb 10, 2020 7:46 am
Full Name: Alberto Cepero
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by acepero »

Hi all!!

I understand that the final script should look like this, right?

Code: Select all

asnp VeeamPSSnapin
Get-VBRJob | ?{$_.JobType -eq "Backup"} | %{
    
    $job = $_
    $JobName = $_.Name 
    $Backup = Get-VBRBackup -Name $JobName
    if ($Backup -eq $null) {
        $BackupName = $JobName.Remove(7,4)
        $Backup = Get-VBRBackup -Name $BackupName    }
    else {
    $lastsession = $job.FindLastSession()
    $Session = $job.FindLastSession()
    foreach($tasksession in $lastsession.GetTaskSessions()) {
    $PointsOnDisk = (get-vbrbackup -Name $job.Name | Get-VBRRestorePoint -Name $tasksession.Name | Measure-Object).Count 
    $BackupTotalSize = [math]::round($Session.Info.Progress.TotalUsedSize/1Gb,2)
    $BackupSize = [math]::round($Session.Info.BackedUpSize/1Gb,2)
    $RepositoryPath = $Backup.Info.DirPath.ToString()
    $LastBackupStart = $Session.CreationTime
    $LastResult = $job.GetLastResult()
    }
	$_ | Get-VBRJobObject | ?{$_.Object.Type -eq "VM"} | Select @{ L="Job"; E={$JobName}}, Name, @{ L="Size"; E={$_.ApproxSizeString}}, @{ L="PointsOnDisk"; E={$PointsOnDisk}}, @{ L="LastResult"; E={$LastResult}}, @{ L="LastBackupStart"; E={$LastBackupStart}}, @{ L="LastBackupTotalSize"; E={$BackupTotalSize}}, @{ L="LastBackupSize"; E={$BackupSize}}, @{ L="RepositoryPath"; E={$RepositoryPath}} | Sort -Property Job, Name
}
}
Anyway, only VM takes me out that are no longer copied, it is not able to remove all existing VMs.
In the second line of the code should I put the name of the job? I do it and it doesn't give me anything back

Thank you so much for your help

oleg.feoktistov
Veeam Software
Posts: 1013
Liked: 366 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by oleg.feoktistov » 1 person likes this post

Hi Alberto,

Yes, should be it. In my lab it works perfectly.
Anyway, only VM takes me out that are no longer copied, it is not able to remove all existing VMs.
Sorry, what do you mean by that?
In the second line of the code should I put the name of the job? I do it and it doesn't give me anything back
This script returns info for all backup jobs, so there is no need to specify the name.
But do you mean this or else?

Code: Select all

asnp VeeamPSSnapin
Get-VBRJob -name "BACKUP-TO-SOBR"| ?{$_.JobType -eq "Backup"} | %{
Best regards,
Oleg

albertwt
Expert
Posts: 724
Liked: 25 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by albertwt »

Hi Oleg,

yes, your script is working as expected.
Since it is executed against Veeam Backup & Replication 10.0.0.4461

There is
WARNING: This cmdlet is obsolete and no longer supported. To get computer backup job use "Get-VBRComputerBackupJob" instead.
--
/* Veeam software enthusiast user & supporter ! */

oleg.feoktistov
Veeam Software
Posts: 1013
Liked: 366 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by oleg.feoktistov »

Hi @albertwt,

It makes sense if you run it against agent backup jobs since we have a whole set of new cmdlets to manage them :wink:

Best regards,
Oleg

veremin
Product Manager
Posts: 18579
Liked: 1853 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by veremin »

Just a tip - to avoid unnecessary warnings you can input WarningAction parameter with "SilentlyContinue" as its value. Thanks!

sumeet.singh
Novice
Posts: 7
Liked: never
Joined: Aug 12, 2020 1:37 pm
Full Name: Sumeet Singh
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by sumeet.singh »

Hello All

Get-VBRJob only gives me VMware backup jobs and there are different hypervisor in veeam backup application.
Is there any other command to get list of all the jobs showing in home -> Jobs -> Backup ?
Using Get-VBRBackup gives list of all jobs but not the vm inside each job and size other details.

Any help would be appreciated.

oleg.feoktistov
Veeam Software
Posts: 1013
Liked: 366 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by oleg.feoktistov » 1 person likes this post

Hi Sumeet,

Get-VBRJob works for VMware and Hyper-V, so should be no issues here.
As for Nutanix, it is represented as custom platform (BackupPlatform: ECustomPlatform). But you still can retrieve related backup jobs along with those of other platforms using .NET method below:

Code: Select all

[Veeam.Backup.Core.CBackupJob]::GetAll()
Thanks,
Oleg

sumeet.singh
Novice
Posts: 7
Liked: never
Joined: Aug 12, 2020 1:37 pm
Full Name: Sumeet Singh
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by sumeet.singh »

Hi Oleg

Is there any way to do it in Powershell?
As of now i don't want to use .NET

jhoughes
Veeam Software
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Austin, TX
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by jhoughes » 1 person likes this post

You can run that exact code in PowerShell.
Husband, Father, Solutions Architect, Geek Extraordinaire | @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion

sumeet.singh
Novice
Posts: 7
Liked: never
Joined: Aug 12, 2020 1:37 pm
Full Name: Sumeet Singh
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by sumeet.singh »

As i need details of all job which is appearing like:
job Name:
job per vm:
per vm size:
retention policy:

Using these command [Veeam.Backup.Core.CBackupJob]::GetAll() which is equal to using GET-VBRBackup gives all jobs result but how can i achieve every job details.

using below scripts gives only Vmware and hyper-V, how can i get all other jobs detail?

asnp VeeamPSSnapin
Get-VBRJob | ?{$_.JobType -eq "Backup"} | %{

$job = $_
$JobName = $_.Name
$Backup = Get-VBRBackup -Name $JobName
$lastsession = $job.FindLastSession()
$Session = $job.FindLastSession()
foreach($tasksession in $lastsession.GetTaskSessions()) {
$PointsOnDisk = (get-vbrbackup -Name $job.Name | Get-VBRRestorePoint -Name $tasksession.Name | Measure-Object).Count
$BackupTotalSize = [math]::round($Session.Info.Progress.TotalUsedSize/1Gb,2)
$BackupSize = [math]::round($Session.Info.BackedUpSize/1Gb,2)
$RepositoryPath = $Backup.Info.DirPath.ToString()
$LastBackupStart = $Session.CreationTime
$LastResult = $job.GetLastResult()
}
$_ | Get-VBRJobObject | ?{$_.Object.Type -eq "VM"} | Select @{ L="Job"; E={$JobName}}, Name, @{ L="Size"; E={$_.ApproxSizeString}}, @{ L="PointsOnDisk"; E={$PointsOnDisk}}, @{ L="LastResult"; E={$LastResult}}, @{ L="LastBackupStart"; E={$LastBackupStart}}, @{ L="LastBackupTotalSize"; E={$BackupTotalSize}}, @{ L="LastBackupSize"; E={$BackupSize}}, @{ L="RepositoryPath"; E={$RepositoryPath}} | Sort -Property Job, Name
}

jhoughes
Veeam Software
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Austin, TX
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by jhoughes »

It is not equivalent to Get-VBRBackup, but rather Get-VBRJob.

You can take what Oleg posted and capture it into a variable, or just use it to replace Get-VBRJob in line 2 of your code.
Husband, Father, Solutions Architect, Geek Extraordinaire | @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion

sumeet.singh
Novice
Posts: 7
Liked: never
Joined: Aug 12, 2020 1:37 pm
Full Name: Sumeet Singh
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by sumeet.singh »

okay i got it.As you suggested i have replaced the line in above code but it throws error.

You cannot call a method on a null-valued expression.
At C:\Untitled11.ps1:12 char:29
+ foreach($tasksession in $lastsession.GetTaskSessions()) {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull


the new code is :

asnp VeeamPSSnapin


[Veeam.Backup.Core.CBackupJob]::GetAll() | %{

$job = $_
$JobName = $_.Name
$Backup = Get-VBRBackup -Name $JobName
$lastsession = $job.FindLastSession()
$Session = $job.FindLastSession()

foreach($tasksession in $lastsession.GetTaskSessions()) {
$PointsOnDisk = (get-vbrbackup -Name $job.Name | Get-VBRRestorePoint -Name $tasksession.Name | Measure-Object).Count
$BackupTotalSize = [math]::round($Session.Info.Progress.TotalUsedSize/1Gb,2)
$BackupSize = [math]::round($Session.Info.BackedUpSize/1Gb,2)
$Option = $Job.BackupStorageOptions.RetainCycles
$LastBackupStart = $Session.CreationTime
$LastResult = $job.GetLastResult()
}
$_ | ?{$_.Object.Type -eq "VM"} | Select @{ L="Job"; E={$JobName}}, Name, @{ L="Size"; E={$_.ApproxSizeString}}, @{ L="RetentionPoint"; E={$Option}}, @{ L="LastResult"; E={$LastResult}}, @{ L="LastBackupStart"; E={$LastBackupStart}}, @{ L="LastBackupTotalSize"; E={$BackupTotalSize}}, @{ L="LastBackupSize"; E={$BackupSize}} | Sort -Property Job, Name
}

jhoughes
Veeam Software
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Austin, TX
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by jhoughes » 1 person likes this post

That means that at least one of your backup sessions doesn’t have a valid task session.

You should capture the results of $lastsession.GetTaskSessions() into a variable first and then run your for each loop against that.

The real issue is that you don’t have any logic or error handling to check for invalid input before that entire code lock runs, so even the ab,I’ve fix may not resolve everything.
Husband, Father, Solutions Architect, Geek Extraordinaire | @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion

sumeet.singh
Novice
Posts: 7
Liked: never
Joined: Aug 12, 2020 1:37 pm
Full Name: Sumeet Singh
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by sumeet.singh »

okay got your point, so still stuck is there any work around to get the following details of the job which is not be shown by GET-VBRJob?
job Name:
job per vm:
per vm size:
last result:

oleg.feoktistov
Veeam Software
Posts: 1013
Liked: 366 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by oleg.feoktistov »

Hi Sumeet,

Answering your question,
Job name:

Code: Select all

$job = Get-VBRJob -Name 'JobName'
$job.Name
Job per vm
I don't quite understand. Do you mean task sessions for each vm in a job?

Per vm size:

Code: Select all

$job = Get-VBRJob -Name 'JobName'
$objects = Get-VBRJobObject -Job $job 
foreach ($object in $objects) {
   $object.ApproxSizeString
}
It's a size of VM being backed up.
Or do you mean something else?

Last result:

Code: Select all

$job = Get-VBRJob -Name 'JobName' 
$job.Info.LatestStatus
# or
$job.GetLastResult()
Thanks,
Oleg

sumeet.singh
Novice
Posts: 7
Liked: never
Joined: Aug 12, 2020 1:37 pm
Full Name: Sumeet Singh
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by sumeet.singh »

Hello Oleg

Thank you for the response but i want the last result for Get-VBRBackup like

$job = Get-VBRBackup -Name 'JobName'
$job.Info.LatestStatus

but it seems "Info.LatestStatus" or getLastResult() is not property of get-vbrbackup command.
as get-vbrbackup job gives me all the jobs including agent jobs. so i wanted the result of jobs using command get-vbrbackup

tdewin
Veeam Software
Posts: 1664
Liked: 586 times
Joined: Mar 02, 2012 1:40 pm
Full Name: Timothy Dewin
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by tdewin »

That's because a backup is the result of a job running. They are mostly linked but not always. Imagine a job that has not run yet, there are no "backups" or a "last result". Or if you import a backup (or remove a job), there is no job for that specific backup

From a backup, you can try to find the related job (but again, it might not be linked if it is an imported backup)

Code: Select all

$backup.GetJob()
But not sure if this is really what you want

You can pipe an object to get-member or gm to get it's properties. E.g

Code: Select all

get-vbrbackup | gm

sumeet.singh
Novice
Posts: 7
Liked: never
Joined: Aug 12, 2020 1:37 pm
Full Name: Sumeet Singh
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by sumeet.singh »

Lucas_H, how can i retrieve data like transfered data , duration of backup and message if the backup failed or warning add to these upper script?

oleg.feoktistov
Veeam Software
Posts: 1013
Liked: 366 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by oleg.feoktistov » 1 person likes this post

Hi @sumeet.singh,

All that info you mentioned is related to backup session. You can retrieve it with the following sample script:

Code: Select all

$job = Get-VBRJob -Name 'JobName'
$session = Get-VBRBackupSession -Name "$($job.Name)*" | select -Last 1 #retrieves the last session for the job chosen.
$session.Progress.TransferedSize
$session.Progress.Duration.ToString()
$session.Result
Thanks,
Oleg

doctor_r
Novice
Posts: 4
Liked: never
Joined: Jun 18, 2020 5:15 am
Full Name: Ryan C
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by doctor_r »

This is all good, however I seem to have thrown a wrench into thing using only VM tags as my VM targets in a job.
Name output is shown only as the tags not VM objects in the job.
Any ideas on how to loop through session info per job at a tag level?

doctor_r
Novice
Posts: 4
Liked: never
Joined: Jun 18, 2020 5:15 am
Full Name: Ryan C
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by doctor_r »

Also curious on proper usage of Get-VBRRetentionPolicy
My job has GFS set, however Get-VBRRetentionPolicy output of a given job shows as simple? Maybe another byproduct of tag usage rather than direct VM objects in a job?

oleg.feoktistov
Veeam Software
Posts: 1013
Liked: 366 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by oleg.feoktistov »

Hi Ryan,

First, in regards to tags. Objects you add directly to your job don't have any other children. So, if you add any entity container (VM tag, resource pool, folder etc.), you cannot just expand all the entities within as on this stage it is not an inventory anymore.
If you need to get VM names inside VM tags, you can use PowerCLI to retrieve VM by tags you added to the job.

Now, about Get-VBRRetentionPolicy. As the article states, this cmdlet returns retention policy solely for backup copy jobs of certain types.
So, may not work correctly with other types.

Thanks,
Oleg

doctor_r
Novice
Posts: 4
Liked: never
Joined: Jun 18, 2020 5:15 am
Full Name: Ryan C
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by doctor_r »

Thanks Oleg,
Do you have any reference on recursion of the VM objects from tags.
What I am ultimately after is where this thread started, to report retention of specific VM items inside a job, to ensure adherence to GFS.
I can see the default retention (days/Backup Points) is easily derived, but I am still confused on getting a visual for GFS retention points.

Understood that Get-VBRRetentionPolicy only applies to Backup Copy jobs

oleg.feoktistov
Veeam Software
Posts: 1013
Liked: 366 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Powershell to list Backup Job name, VMs and its retention?

Post by oleg.feoktistov »

By getting VMs by VM tags backed up I meant this sample:

Code: Select all

$job = Get-VBRJob
Connect-VIServer -Server 'vcenter'
$tag = Get-VBRJobObject -Job $job
$vms = Get-VM -Tag $tag.Name 
But if you are after checking restore points count for VMs already backed up in per-VM backup chain,
you can try this:

Code: Select all

 $job = Get-VBRJob -Name 'Backup job'
$backup = Get-VBRBackup -Name $Job.Name
$objects = $backup.GetObjects()
foreach ($object in $objects) {
  $storages = $backup.GetAllStorages() | where {$_.FilePath -match $object.Name}
  $object | select Name, @{n='RPCount';e={$storages.Count}}
} 
It should also work if VM tags are job objects.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests