PowerShell script exchange
Post Reply
marius roma
Veteran
Posts: 459
Liked: 5 times
Joined: Feb 01, 2012 12:04 pm
Full Name: Mario
Contact:

Listing replicated VMs

Post by marius roma »

I need to have a list of replicated VMs with the date of the latest successfull replica.
Replicas folder provides a list of replicated VMs but the date looks to be the date of the first replica, not the latest.
I need to see the current state of replicated VMs in order to say if a replica is current or not.
Can I get such list from Veeam B&R console or should I use PowerShell or any other tool?
Regards
marius
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Listing replicated VMs

Post by Vitaliy S. »

Hi Marius,

You can either try to create such report with PowerShell or just generate one of these predefined reports in Veeam ONE:
1. Protected VMs
2. Latest Backup Job Status
3. VM Backup Status

Thanks!
pcarpenter
Service Provider
Posts: 1
Liked: never
Joined: Jun 07, 2016 1:35 pm
Full Name: Patrick Carpenter
Contact:

Re: Listing replicated VMs

Post by pcarpenter »

This should get you started. You can build a hash table and output this information however you'd like:

Code: Select all

$ReplicaSessions = (Get-VBRBackupSession | ? {$_.JobType -like "Replica"} | Get-VbrTaskSession
[array]$VMs = $ReplicaSessions.Name

Foreach ($Vm in $VMs) {
$VmReplicaSessions = $ReplicaSessions | ? {$_.Name -like $Vm}
$RecentReplicaSession = $VmReplicaSessions | Sort-Object { $_.Info.QueuedTime } | Select -Last 1
$JobName = RecentReplicaSession.JobName

$ReplicaPoints = Get-VBRReplica -Name $JobName | Get-VBRRestorePoint
$VmReplicaPoints = $ReplicaPoints | ? {$_.Name -like $Vm }
$VmReplicaPoints = $VmReplicaPoints | Sort-Object {$_.CreationTime};
$RecentReplica = $VmReplicaPoints | ? {$_.IsConsistent -like "True"} | Select -Last 1;
[int32]$ReplicaAge = (New-TimeSpan -Start $RecentReplica.CreationTime -End (Get-Date) ).TotalHours
Write-Host "$Vm`, $JobName`, $ReplicaAge"
}

marius roma
Veteran
Posts: 459
Liked: 5 times
Joined: Feb 01, 2012 12:04 pm
Full Name: Mario
Contact:

[MERGED] Extract job schedule

Post by marius roma »

I have several jobs, each one with a different schedule.
I need to extact a list of all the jobs and, for each job, the scheduled start time and the days the job is scheduled to start, i.e.:
Job001 - 22:30 - 1,2,3,5,7
or
Job002 - 23:00 - Mo,Tu,We,Sa,Su
Is there any sample I can start from?
Regards
Marius
DGrinev
Veteran
Posts: 1943
Liked: 247 times
Joined: Dec 01, 2016 3:49 pm
Full Name: Dmitry Grinev
Location: St.Petersburg
Contact:

Re: Extract job schedule

Post by DGrinev »

Hi Mario,

You can obtain the information you're interested in by using Veeam ONE report called Protected VMs Job Schedule.
Regarding Powershell I found a script on the forum that should solve your request. Thanks!
marius roma
Veteran
Posts: 459
Liked: 5 times
Joined: Feb 01, 2012 12:04 pm
Full Name: Mario
Contact:

[MERGED] Listing jobs and VMs

Post by marius roma »

I need to create a report including a list of all backup jobs currently existing and, for each job:
  • a list of the VMs included in the job (including the VMs that are porocessed because they are inside a given folder)
  • the scheduling information.
I know that such information is available via Veeam ONE licensed edition, but at the moment it is not available and I cannot use the trial version because the script must be executed every week from now to the future.
Is there an sample I can start from?
Regards
Marius
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Extract job schedule

Post by Vitaliy S. »

Marius,

You can start with the script mentioned above by Dmitry to review the schedule of your jobs, plus take at the example that was given by Patrick Carpenter to list all VMs in the job.

Hope this helps!
jroback
Novice
Posts: 8
Liked: 2 times
Joined: Nov 06, 2010 12:24 am
Full Name: Jeff Roback
Contact:

Re: Listing replicated VMs

Post by jroback » 2 people like this post

The above script had a couple of typos, here's a revised version. Haven't validated 100% that this does what is expected, but it now runs without errors ;-)

Code: Select all

$ReplicaSessions = (Get-VBRBackupSession | ? {$_.JobType -like "Replica"} | Get-VbrTaskSession)
[array]$VMs = $ReplicaSessions.Name

 ForEach ($Vm in $VMs) {
$VmReplicaSessions = $ReplicaSessions | ? {$_.Name -like $Vm}
$RecentReplicaSession = $VmReplicaSessions | Sort-Object { $_.Info.QueuedTime } | Select -Last 1
$JobName = $RecentReplicaSession.JobName

$ReplicaPoints = Get-VBRReplica -Name $JobName | Get-VBRRestorePoint
$VmReplicaPoints = $ReplicaPoints | ? {$_.Name -like $Vm }
$VmReplicaPoints = $VmReplicaPoints | Sort-Object {$_.CreationTime};
$RecentReplica = $VmReplicaPoints | ? {$_.IsConsistent -like "True"} | Select -Last 1;
[int32]$ReplicaAge = (New-TimeSpan -Start $RecentReplica.CreationTime -End (Get-Date) ).TotalHours
Write-Host "$Vm`, $JobName`, $ReplicaAge"
}
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 23 guests