PowerShell script exchange
tcz
Lurker
Posts: 1
Liked: never
Joined: Jun 27, 2018 8:47 pm
Full Name: Thomas Czarnetzki
Contact:

[MERGED] VM-Backups completed in JOB

Post by tcz » Jul 22, 2019 12:42 pm

Dear,

i need a powershell-script who returns me, who many VMs/Backups in a Job are completed/running.
I have found in the Forum the following snipped, who list me the VMs in a Job - that works fine:

Code: Select all

Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue

$jobname = "xyz"

# Get entire vCenter VM hierarchy using VM and Template view for object [ath
$vmsandtemplates = Find-VBRViEntity -VMsAndTemplates
$vmfoldertree = $vmsandtemplates |? {$_.Type -eq "Vm"}
$vmfolders = $vmsandtemplates |? {$_.Type -eq "Folder"}

# Get Backup Job
$job = Get-VBRJob -Name $jobname | Sort -Property Name

write-Host $job.Name
# Get all included objects in job (assumes single folders)
$jobobjs = $job.GetObjectsInJob() | ?{$_.Type -eq "Include"}
# Get path for folder object
$jobobjid = $jobobjs.GetObject().Info.HostId.ToString() + "_" + $jobobjs.GetObject().Info.ObjectId
$jobobjpath = ($vmfolders | ?{$_.Id -eq "$jobobjid"}).Path
write-host $jobobjpath
# Get subset of VMs that are in the folder
$vmsinfolder= $vmfoldertree |?{$_.Path -like "$jobobjpath*"} | Sort -Property Name

ForEach ($vm in $vmsinfolder) {
    write-host "   " $vm.Name
}
But who i can now receive the info, when the lastbackup of vm is finished, or currently running?
For the Job i have found a lot of solutions, but i need the info for VMs in a job.

Target-Output is, e.g. "13 of 35 VMs completed in Job xyz".

Kind regards,
tcz

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

Re: My Veeam Report v9.5.1

Post by veremin » Jul 22, 2019 2:24 pm

The report provided above should have information you're after. Thanks!

jochot
Expert
Posts: 102
Liked: 5 times
Joined: Jul 13, 2017 12:34 pm
Contact:

[MERGED] Reporting with Powershell (Sessions? Jobs?)

Post by jochot » Jul 22, 2019 2:55 pm

Hey,

I'd like to use powershell to create Reports for our Auditers.
Now I know that this is a Job for VeeamONE, but we don't have VeeamONE.
The report needs to show that the backup for a Job or VM ran on a daily basis between date X and Y & I would like to have additional info for failed jobs.
Basically a List with the following infos: [Jobname, BackupStart, BackupEnd, Result]

My two approaches up until now are:
JobObject:

Code: Select all

$JobName = "asdf" 
$JobObj = Get-VBRJob -name $JobName 
$lastBaseSession = $JobObj.FindLastBaseSession() 
echo $lastBaseSession
Here I get the latest results from the backup job, so from the latest run, haven't found a way to get more than one session displayed

Sessions:

Code: Select all

$VbrJobSessions = Get-VBRBackupSession -Name $Jobname
echo $VbrJobSessions
Here I get the first session returned.

As I understand it, a Session is one backup run, so I should have one session per day (daily backup)
I would assume, that you get all the sessions in $VbrJobSessions for $Jobname & can foreach($JobSession in $VbrJobSessions) through all the Sessions & fetch the info you need from the sessions for each day, but that doesn't seem to work.
(https://helpcenter.veeam.com/docs/backu ... l?ver=95u4 "Returns jobs sessions." 'Sessions' -> plural, but could also mean latest Sessions for all jobs?)

Does anyone know where I can find history info about a Job or a VM in Powershell? Am I missing something?

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

Re: My Veeam Report v9.5.1

Post by veremin » Jul 22, 2019 6:22 pm

Kindly, check the report above - should answer your requirements.

Search this subforum in case it does not - there are multiple threads talking about the very same matter.

Thanks!

jochot
Expert
Posts: 102
Liked: 5 times
Joined: Jul 13, 2017 12:34 pm
Contact:

Re: My Veeam Report v9.5.1

Post by jochot » Jul 23, 2019 11:55 am

had a look, that's 3000lines of powershell code, I honestly don't have a clue where to start looking in this script to find what I need.
I just want to have a history of Backup Sessions for one Backup Job, basically what happends when you click on "create report".
But I can only find the last session

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

Re: My Veeam Report v9.5.1

Post by veremin » Jul 23, 2019 12:43 pm

There are multiple examples on this forum how this can be achieved. So, feel free to search it through to find one that meets your expectations best (you can start with this report, for instance). Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests