Listing all the times all VMs were replicated

PowerShell script exchange

Listing all the times all VMs were replicated

Veeam Logoby marius roma » Sun Oct 25, 2015 11:03 am

In order to perform statistic analysis I need to create a job to list all the times all VMs were replicated or at least the last 50 time each VM was replicated, regardless of the job.
For each time a given VM was replicated I need to record the start and end time and the rersult (Success, warning, failed...).
The task could be described as something like "For each VM in each job list all the times the VM was replicated".
I made some tests but the results I get are not complete, so I presume I am getting the wrong data.
Is there any sample script I can start from?
Regards
marius
marius roma
Expert
 
Posts: 358
Liked: 3 times
Joined: Wed Feb 01, 2012 12:04 pm
Full Name: Mario

Re: Listing all the times all VMs were replicated

Veeam Logoby v.Eremin » Tue Nov 03, 2015 4:54 pm

Should it be a list of replicated VMs that still have restore points or more like historical report that will provide information regarding even those VMs that already have no replication restore points?
v.Eremin
Veeam Software
 
Posts: 14019
Liked: 1051 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Listing all the times all VMs were replicated

Veeam Logoby marius roma » Wed Nov 04, 2015 7:47 am

The second Solution would be far better...
Regards
marius
marius roma
Expert
 
Posts: 358
Liked: 3 times
Joined: Wed Feb 01, 2012 12:04 pm
Full Name: Mario

Re: Listing all the times all VMs were replicated

Veeam Logoby v.Eremin » Thu Nov 05, 2015 12:14 am 1 person likes this post

Unfortunately, I'm out of the office at the moment (on a sick leave, actually), so, I can only propose the algorithm that I'd implement.

Firstly, I'd get the list of all sessions, using Get-VBRBackupSession commandlet.

Secondly, I'd filter out those that are not replication ones (type is not equal to replica) via where-object commandlet.

Thirdly, I'd leverage Get-VBRTaskSession commandlet to get all VMs specific sessions within replication job sessions.

Fourthly, I'd select specific properties out of the list of existing task session, like VM name, result, start and end time.

Fifthly, I'd format the output a bit, so that, information is shown in required order (all sessions specific to first VM, then, to second, etc.)

Thanks.
v.Eremin
Veeam Software
 
Posts: 14019
Liked: 1051 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

[MERGED] Listing session start and end time

Veeam Logoby marius roma » Fri Jan 12, 2018 1:15 pm

I need to get a list of the last 10 backup sessions for each job with start time, end time and result.
I need to detect as well if health check was performed for the given session.
My code looks like:
Code: Select all
foreach ($Job in (Get-VBRJob | where {$_.JobType -eq "Backup"}))
    {
    foreach ($Session in (Get-VBRBackupSession | Where {$_.Jobname -eq $Job.name}) | Sort creationtime -Descending | select -First 10)
        {
        ...
        $session_start =
        $session_end =
        $session_result =
        $session_Health_Check =
        ...
        }
     }

Which properties should I use to get the values I need?
Regards
Marius
marius roma
Expert
 
Posts: 358
Liked: 3 times
Joined: Wed Feb 01, 2012 12:04 pm
Full Name: Mario

Re: Listing all the times all VMs were replicated

Veeam Logoby marius roma » Mon Jan 15, 2018 10:05 am

Any update?
Regards
marius
marius roma
Expert
 
Posts: 358
Liked: 3 times
Joined: Wed Feb 01, 2012 12:04 pm
Full Name: Mario

Re: Listing all the times all VMs were replicated

Veeam Logoby v.Eremin » Mon Jan 15, 2018 5:52 pm

The general approach is described above, and multiple examples of how the requested information can be received are available on our forums. Thanks.
v.Eremin
Veeam Software
 
Posts: 14019
Liked: 1051 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Listing all the times all VMs were replicated

Veeam Logoby marius roma » Tue Jan 16, 2018 4:54 pm

I am working with a script based on the following loops:
Code: Select all
foreach ($Job in (Get-VBRJob | where {$_.JobType -eq "Backup"}))
 {
 foreach ($Session in (Get-VBRBackupSession | Where {$_.Jobname -eq $Job.name}) | Sort creationtime -Descending | select -First 3)
     {
     ...
     ...
     }
 }

It works, but it looks extremely slooooow.
Can anybody please suggest a smarter aproach?
Regards
Marius
marius roma
Expert
 
Posts: 358
Liked: 3 times
Joined: Wed Feb 01, 2012 12:04 pm
Full Name: Mario

Re: Listing all the times all VMs were replicated

Veeam Logoby v.Eremin » Wed Jan 17, 2018 11:25 am

You might try to run backup session only once, save the results into hash table and operate with the hash table afterwards; should save you the time, since the Get-VBRBackupSession cmdlet will be executed only once. Thanks.
v.Eremin
Veeam Software
 
Posts: 14019
Liked: 1051 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: Yahoo [Bot] and 1 guest