PowerShell script exchange
Post Reply
kmertens
Service Provider
Posts: 6
Liked: never
Joined: Dec 26, 2016 1:55 pm
Location: Belgium
Contact:

List vm's in jobs, not showing all vm's and duplicates

Post by kmertens »

Hi

I am writing a script to list all the vm's that are being backuped in our environment. vCenter combined with vCloud.
But for some reason some vm's are having different values which makes it difficult to filter in them.
I have 3 issues:

First: Jobs are having duplicates objects. The only difference seems to be the Type and PolicyType:
Id : 7f8b3c22-0d3a-4a4d-a54f-d132847036a4
ObjectId : d66e5b49-720d-4d47-9e02-ce937c8334f1
Object : Name: ICCPROXY02 (69de819d-460f-4401-8e75-5532f8cf53fb)
Filter :
Role : EPolicy
Name : ICCPROXY02 (69de819d-460f-4401-8e75-5532f8cf53fb)
Type : GuestCredsChild
Location : BEANONDVC01.ad.ondit.net\ant.ondit.net\BEADONDVCLUS01\IRIS_ICC ovDC (a6c0c97d-3b7a-4da6-ab58-306c7991faa6)\ICCPROXY02 (69de819d-460f-4401-8e75-5532f8cf53fb)
OrderNo : 0
ApproxSizeString : 0,0 B
Info : Veeam.Backup.Model.CDbObjectInJobInfo
JobId : d12a769e-1931-49ca-963b-e4bddca8b2a2
IsFolder : False
IsIncluded : False
IsVssChild : False
IsExcludeDisksChild : False
IsExcluded : False
IsExtended : False
PolicyType : GuestCreds
Id : 0b53197b-adcc-4272-96fd-7a7c994ed8bb
ObjectId : d66e5b49-720d-4d47-9e02-ce937c8334f1
Object : Name: ICCPROXY02 (69de819d-460f-4401-8e75-5532f8cf53fb)
Filter :
Role : EPolicy
Name : ICCPROXY02 (69de819d-460f-4401-8e75-5532f8cf53fb)
Type : ExtendedChild
Location : BEANONDVC01.ad.ondit.net\ant.ondit.net\BEADONDVCLUS01\IRIS_ICC ovDC (a6c0c97d-3b7a-4da6-ab58-306c7991faa6)\ICCPROXY02 (69de819d-460f-4401-8e75-5532f8cf53fb)
OrderNo : 0
ApproxSizeString : 0,0 B
Info : Veeam.Backup.Model.CDbObjectInJobInfo
JobId : d12a769e-1931-49ca-963b-e4bddca8b2a2
IsFolder : False
IsIncluded : False
IsVssChild : False
IsExcludeDisksChild : False
IsExcluded : False
IsExtended : True
PolicyType : Extended
Problem with this is that I can't filter on this because then I filter other VM's not part of an oVDC because they might also have this type.


Second problem: An oVDC with 7 VM's in 2 vapps (1 excluded) doesn't have any objects I can use. The only objects in that job is the oVDC itself and the excluded machine.
In veeam B&R you can see all the 6 machines being backed-up just fine.
Type: VM
Policy: None
Name: TTS

Type: Template
Policy: None
BEADSPADB02 (b6070796-f4bb-4fe8-ac23-05731d537460)

Third: I saw that some machines have the type "NfcDir". What is this type ?

This is the code I am using

Code: Select all

$objects = $Jobs.GetObjectsInJob()
$type = $objects.GetObject().Type

foreach ($object in $objects) {
    $type = $object.GetObject().Type
    Write-Output ""
    Write-Output "Type:",$type   
    Write-Output "Policy:",$object.PolicyType     
    if ($type -eq "VM") {        
        Write-Output "Name",$object.Name
    } else {        
        Write-Output "No HIT:", $object.Name
    }
}
Thanks in advance !
tsightler
VP, Product Management
Posts: 6035
Liked: 2860 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: List vm's in jobs, not showing all vm's and duplicates

Post by tsightler »

kmertens wrote:First: Jobs are having duplicates objects. The only difference seems to be the Type and PolicyType:
Problem with this is that I can't filter on this because then I filter other VM's not part of an oVDC because they might also have this type.
You'll pretty much have to filter these because these objects are not representative of the objects included in the job, as noted that represent various other settings or exclusions that may be applied to an object. I'll try to give an example:

Imagine I have a job that has a folder included, the folder has 10 VMs. Perhaps one of these VMs, vm01, needed to be excluded from the job, and another vm, say, vm02, needed a difference set of credentials. When you queried the objects in the job you would get three objects, an "Include" object that would be the folder, then an Exclude object, and a GuestVSS object (those are not the exact names). These objects are all evaluated together at the time the job is run to actually determine what VMs the job will actually backup, exclude, etc.
kmertens wrote:Second problem: An oVDC with 7 VM's in 2 vapps (1 excluded) doesn't have any objects I can use. The only objects in that job is the oVDC itself and the excluded machine.
Right, this is what I'm saying above, the only object included in the job is the oVDC, which is a container object, and the specific VM that is exlcuded (as an exclude object). This list of objects is evaluated at run time to determine what vApps and VMs will actually be backed up during that run, because it could be different from one day to the next since vApps and VMs can be added/removed from the oVDC at any time.
kmertens wrote:Third: I saw that some machines have the type "NfcDir". What is this type ?
Hmm...you've got me on that one.

The reality is, if you're adding container objects to jobs, it's very difficult to determine exactly what VMs are included by just quering the job objects since the included objects are evaluated at run time. This is especially true when you take into account exclusions, etc. You'd have to enumerate the container and apply the same exclude logic for any object of type exclude. You can certainly do this, but it can get complex if you have container based includes and container based excludes.

Most scripts that attempt to do this use the most recent backup runs, or a combination of the runs from the last several days. This is not perfect, since it's only as updated as the most recent backup run, but it's far easier.
kmertens
Service Provider
Posts: 6
Liked: never
Joined: Dec 26, 2016 1:55 pm
Location: Belgium
Contact:

Re: List vm's in jobs, not showing all vm's and duplicates

Post by kmertens »

Hi Tom

Thanks for your response.

We would like to do it this way (live) because then we can live compare changes to a job.
So if I understand correctly. If we want to list all active vm's in a job, we exclude all "GuestCredsChild" and type "Excluded"
And include objects in a container (but still excluded the same things as above)

Another question, how do I list the objects in that container, or even know in the first place if there are any objects in it ? Since it has the same type as a normal VM ?

Thanks again in advance :)
tsightler
VP, Product Management
Posts: 6035
Liked: 2860 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: List vm's in jobs, not showing all vm's and duplicates

Post by tsightler »

kmertens wrote:We would like to do it this way (live) because then we can live compare changes to a job.
So if I understand correctly. If we want to list all active vm's in a job, we exclude all "GuestCredsChild" and type "Excluded"
And include objects in a container (but still excluded the same things as above)
i understand your goal, I'm just pointing out that this is more complex than it at first appears. I'd say you can completely filter out anything other than Include and Exclude objects, then you would need to determine the include objects, enumerate them if they are container based objects, do the same for any exclude objects, then combine the list of fully enumerated objects to create a final list of included objects.
kmertens wrote:Another question, how do I list the objects in that container, or even know in the first place if there are any objects in it ? Since it has the same type as a normal VM ?
If you look at $jobobj.Object.Type and $jobobj.Object.Info.HierarchyType you can determine whether the object is a VM, folder, resource pool, etc., and what hierarchy it was selected from. You could then use the object path to enumerate that object using Find-VBRViEntity. It could certainly be coded, but it's a lot of steps to get right.
Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests