Get-VBRRestorePoint - Most recent replica

PowerShell script exchange

Get-VBRRestorePoint - Most recent replica

Veeam Logoby dcd62 » Wed Apr 27, 2016 1:42 am

I'm scripting the permanent failover and want to commit the most recent snapshot. The example I found in the helpcenter shows:
PS C:\PS> Get-VBRRestorePoint -Name "WebServer_replica" | Sort-Object $_.creationtime -Descending | Select -First 1 | Start-VBRViReplicaFailover -Reason "Configuration recovery" -RunAsync -Definite

If I run the Get-VBRRestorePoint command just to list the most recent replica with the "-First" switch, an older replica than if I use the "-Last" switch.
Which should give me the most recent replica?
thanks

PS C:\Users> Get-VBRRestorePoint -Name $VM | Sort-Object $_.creationtime -Descending | Select -First 1
VM Name Creation Time Type Failoved
------- ------------- ---- --------
VEEAMTEST01 4/26/2016 8:01:47 PM Snapshot


PS C:\Users> Get-VBRRestorePoint -Name $VM | Sort-Object $_.creationtime -Descending | Select -Last 1
VM Name Creation Time Type Failoved
------- ------------- ---- --------
VEEAMTEST01 4/26/2016 9:24:41 PM Snapshot
dcd62
Enthusiast
 
Posts: 29
Liked: 4 times
Joined: Wed Aug 20, 2014 1:00 pm

Re: Get-VBRRestorePoint - Most recent replica

Veeam Logoby v.Eremin » Wed Apr 27, 2016 9:14 am

Generally speaking, in the provided example the last restore point should be returned by combination of -descending and -first 1 parameters.

What happens if you change the syntax slightly:

Either this:

Code: Select all
Get-VBRRestorePoint -Name $VM | Sort-Object {$_.creationtime} -Descending | Select -First 1


or this way:

Code: Select all
Get-VBRRestorePoint -Name $VM | Sort-Object creationtime -Descending | Select -First 1


Will the code still report an incorrect point?

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

Re: Get-VBRRestorePoint - Most recent replica

Veeam Logoby dcd62 » Thu Apr 28, 2016 12:58 pm 1 person likes this post

Hi, both of your suggestions worked.. thank you very much!!
dcd62
Enthusiast
 
Posts: 29
Liked: 4 times
Joined: Wed Aug 20, 2014 1:00 pm

Re: Get-VBRRestorePoint - Most recent replica

Veeam Logoby v.Eremin » Thu Apr 28, 2016 1:12 pm

You're welcome. Should other help be needed, don't hesitate to let us know. Thanks.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 966 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 9 guests