PowerShell script exchange
Post Reply
dcd62
Enthusiast
Posts: 39
Liked: 4 times
Joined: Aug 20, 2014 1:00 pm
Contact:

Get-VBRRestorePoint - Most recent replica

Post by dcd62 »

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
veremin
Product Manager
Posts: 20284
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get-VBRRestorePoint - Most recent replica

Post by veremin »

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.
dcd62
Enthusiast
Posts: 39
Liked: 4 times
Joined: Aug 20, 2014 1:00 pm
Contact:

Re: Get-VBRRestorePoint - Most recent replica

Post by dcd62 » 1 person likes this post

Hi, both of your suggestions worked.. thank you very much!!
veremin
Product Manager
Posts: 20284
Liked: 2258 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Get-VBRRestorePoint - Most recent replica

Post by veremin »

You're welcome. Should other help be needed, don't hesitate to let us know. Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests