PowerShell script exchange
Post Reply
vy68749p
Novice
Posts: 3
Liked: never
Joined: Jan 26, 2010 7:10 pm
Full Name: Edwin Reed
Contact:

Running a restore via PowerShell

Post by vy68749p »

Can someone post an example of a Set-VBRRestoreVM command?

We have several VMs in a backup file and we need to just create a script to run through and restore each one as the previous one finishes. I don't need anything fancy but I've looked at this off and on for days and I'm getting no where. Any help would be appreciated!

Thanks

Vitaliy S.
Product Manager
Posts: 24246
Liked: 1859 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Running a restore via PowerShell

Post by Vitaliy S. »

Hello Edwin,

Let me check the proper usage of this cmdlet with devs, as I'm not great expert in Powershell. I will update this thread with the example tomorrow.

Thanks!

Gostev
SVP, Product Management
Posts: 26693
Liked: 4273 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Running a restore via PowerShell

Post by Gostev »

Hello Edwin, this is a script one of our customers created to automate VM recovery testing

The blog is in Russian, but Google Translate does a decent job, plus actual PowerShell code does not need translation ;)
http://translate.google.com/translate?h ... pot.com%2F

Hope this helps!

vy68749p
Novice
Posts: 3
Liked: never
Joined: Jan 26, 2010 7:10 pm
Full Name: Edwin Reed
Contact:

Re: Running a restore via PowerShell

Post by vy68749p »

Thanks, I'll download the code and take a look. I think part of the problem here is just my lack of knowledge with PowerShell. I got one of the other guys in the office here to help me out and we got it working for the most part. I do have one question left though and it may take a support person to answer this one...

When using Get-VBRJobRestorePoints, there is a date option...is there a command I can use for the date to always choose the latest backup? This is for our DR recovery and it would be nice to just be able to use -Date "latest" or something like that if that makes sense.

Vitaliy S.
Product Manager
Posts: 24246
Liked: 1859 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Running a restore via PowerShell

Post by Vitaliy S. »

Edwin,

To choose the latest date for your backups, you should be using this cmdlet:

Code: Select all

((Get-VBRJobRestorePoints "JobName" "VmName" | sort CreationTime)[0])
Also here is the Set-VBRRestoreVM cmdlet usage example as requested:

Code: Select all

Set-VBRRestoreVM ((Get-VBRJobRestorePoints "JobName" "VmName" | sort CreationTime)[0]) (Get-VBRJobDestination VcOrEsxName.domain.local "DatastoreName" "ResourcePoolName") -DiskType Source -VMName "NewVmName"
Hope it helps!

vy68749p
Novice
Posts: 3
Liked: never
Joined: Jan 26, 2010 7:10 pm
Full Name: Edwin Reed
Contact:

Re: Running a restore via PowerShell

Post by vy68749p »

Thanks so much! That's exactly what I was needing.

alcidion
Lurker
Posts: 1
Liked: never
Joined: Oct 07, 2011 2:48 am
Full Name: Adam
Contact:

Re: Running a restore via PowerShell

Post by alcidion »

The script doesn't appear to be at that site anymore.

Can you copy/paste it into the forum?

Adam

Vitaliy S.
Product Manager
Posts: 24246
Liked: 1859 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Running a restore via PowerShell

Post by Vitaliy S. »

Hello Adam, here you go the scripts from the blog above. If you're searching for a script to restore VMs with Powershell, then please look through the example in my previous post, should help. Thanks!

squestier
Influencer
Posts: 13
Liked: 5 times
Joined: Apr 12, 2012 9:35 am
Full Name: Sebastien QUESTIER
Contact:

Re: Running a restore via PowerShell

Post by squestier »

hello,

How can we receive the result of the restore with Set-VBRRestoreVm (Success, Failed, Running...)

I cant't figure how to do that because there is no associated job created.

Regards.

Sebastien

Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests