Hello,
I'm currently trying to improve my powershell script that allowed me to monitor the best way possible my veeam jobs and copy jobs for all my customers.
So I have a script that I have implemented in Solarwinds N-Central that works but I have some issues and things to improve on it:
The script :
Add-PSSnapin veeampssnapin
$Sessions = Get-VBRBackupSession #get all of the session information
$Jobs = $Sessions.JobName | select -uniq #get a list of unique backup job names
$numJobs = $Jobs.count #count the number of unique backup jobs
#write-output $numJobs
#write-output $Jobs
$report = @() #declare a blank array
foreach ($session in $Sessions){ #loop through the backup jobs and write the inforamtion into the array
$Info = [Veeam.Backup.Core.CBackupTaskSession]::GetByJobSession($session.id)
$report += $Info
}
$uBackups = $report | Group-Object 'ObjectName' | ForEach-Object{$_.Group | Sort-Object QueuedTime -Descending | Select 'QueuedTime', 'ObjectName', 'Status', 'Reason' -First 1}
for ($n=0; $n -lt $uBackups.count; $n++)
{if ($uBackups[$n].ObjectName -eq $jName) {
$qt = $uBackups[$n].QueuedTime
$obN = $uBackups[$n].ObjectName
$st = $uBackups[$n].Status
$r = $uBackups[$n].Reason
}}
The parameters :
In order to use input/output parameter inside the script, user must provide its name, preceded by $.
Example: parameter named InputParameter must be referred to as $InputParameter to be recognized by the script engine.
Input Parameters:
$jName
Output Parameters:
$qt
$obN
$st
$r
---------------------------------------------------------------------------
1) With this script I have to provide the name in my tool for each virtual machines that I have. Do you have a way to autoprovide the VM name for each jobs ?
3) Get informations only from the last month.
2) I would like to implement the 'Next RUN' and 'TARGET' infos for each jobs that was found. That is possible to do it with this script ?
best Regards
-
- Lurker
- Posts: 2
- Liked: never
- Joined: Dec 05, 2017 2:50 pm
- Full Name: Adrien VANACKERE
- Contact:
-
- Product Manager
- Posts: 20677
- Liked: 2382 times
- Joined: Oct 26, 2012 3:28 pm
- Full Name: Vladimir Eremin
- Contact:
Re: Improve my current Veeam Backup & Replication/Cloud scri
Query vCenter server with Find-VBRViEntity cmdlet, use $_.Type -eq "VM" as filter option (you can double check the syntax on PowerShell subforum; there should be plenty of examples) .1) With this script I have to provide the name in my tool for each virtual machines that I have. Do you have a way to autoprovide the VM name for each jobs ?
Kindly, check previous threads, as this topic has been discussed several times already.2) I would like to implement the 'Next RUN' and 'TARGET' infos for each jobs that was found. That is possible to do it with this script ?
Filter task sessions based on CreationTime parameter (you need only ones created within the last 30 days or so; current date - 30 days).3) Get informations only from the last month.
Thanks.
Who is online
Users browsing this forum: Amazon [Bot], yusuke and 27 guests