Loading
Make sure you have installed the Veeam B&R Console (included on the server)
Loading and checking snapin
get-pssnapin
Add-PSSnapin veeampssnapin
get-pssnapin
Listing all cmdlets
get-command -Module veeampssnapin
get-command -module veeampssnapin -noun VBRServer
get-command -Module veeampssnapin -noun VBRJob
function veeamgcm { param($n) gcm -module veeampssnapin | ? { $_.noun -match "$n" }}
veeamgcm job
First steps, connecting and starting a job
Connect-VBRServer -server 192.168.1.152 -Credential (get-credential -message "VBR" -UserName "Administrator")
Get-VBRJob
Get-VBRJob | select name,jobtype
Get-VBRJob -Name "Backup Job 1"
Get-VBRJob -Name "Backup Job 1" | Start-VBRJob
Get-VBRJob -Name "Backup Job 1" | Start-VBRJob -RunAsync
Disconnect-VBRServer
The Last Session
Get-VBRBackupSession | Sort-Object -Property "EndTime" -Descending| select name,result,endtime
$job = get-vbrjob -Name "Backup Job 1"
$job.FindLastSession() | select name,result,state,endtime
Let's make a very simple report
import-module PowerStartHTML
$ps = New-PowerStartHTML -title "Hello PowerStartHTML!"
class JobStatus {
$Name;$Run;$Result;$State;JobStatus($name,$run,$result,$state) { $this.Name = $name;$this.Run = $run;$this.result = $result;$this.state = $state;}
}
$jobs = get-vbrjob
$table = @()
foreach ($job in $jobs) {
$last = $job.FindLastSession()
if ($last -ne $null) {
$table += new-object JobStatus($job.name,$last.endtime,$last.result,$last.state)
} else {
$table += new-object JobStatus($job.name,"<none>","<none>","<none>")
}
}
$table | Add-PowerStartHTMLTable -psHtml $ps -tableTitle "Jobs" -tableClass "table table-striped"
$ps.Save("report.html")