I am doing some redesigning of our backup jobs, and want to merge multiple jobs to larger jobs.
Being an IT-pro, doing this manually is just something I don't do, so I turned to Powershell to automate this process.
Using Get-VBRJob, Get-VBRJobObject and Add-VBRHvJobObject I have tried automating this process, but it seems like the objects I get when doing "Get-VBRJobObject" isn't usable as Entity in the "Add-VBRHvJobObject" cmdlet.
What I have done to make this happen using powershell is doing a Find-VBRHvEntity first, then using the Add-VBRHvJobObject after, but this is enumerating the cluster every time it is doing the find (it takes between 60-120 seconds for every find). This means adding 60 VMs takes me between one and two hours - automated still, but very slow!
Any help in writing the proper script/cmdlet to add all objects from one job to another (which goes fast) would be highly appreciated!
The problem I am having, is that for each "Find-VBRHvEntity" it is enumerating the cluster, which is causing each line to take "forever" (in this case forever equals to 1-2 minutes). So it have just taken me 90 minutes to loop between a table of 50 objects.
Is there no way I can do this faster?
Please give me some examples if possible - thanks!
Kindly, check the link I've provided - it contains an example.
The idea here is to run Find-VBRHvEntity only once, assign its result to a hash table ( $vms=@{} ) and, starting from that moment, work with the hash table, instead of querying infrastructure directly.
1) Get an old backup job
2) Get its source objects
3) Find VMs in virtual infrastructure which correspond to the gotten objects (object references comparison)
4) Get a new backup job
5) Add objects returned on step 3 to the new backup job
Let me illustrate it with simple example that doesn't contain cycle (necessary to get all source objects) and hash table (required to speed up the process):