PowerShell script exchange
Post Reply
tech@SLOCOE.ORG
Novice
Posts: 3
Liked: never
Joined: May 11, 2023 5:23 pm
Full Name: SLOCOE Tech
Contact:

Restore VM to Different Host

Post by tech@SLOCOE.ORG »

I need to restore a production VM to another host periodically as a sandbox VM.
I have created the following Powershell script:

Code: Select all

clear
Write-Output "Restore VM to a Different Host"
Connect-VBRServer -Server "Veeam Server IP" -User "Admin" -Password "Password"
$backup = Get-VBRBackup -Name "Group 6 Weekly Incremental_"  
$restorepoint = Get-VBRRestorePoint -Name "SFTP" -Backup $backup | Sort-Object –Property CreationTime –Descending | Select-Object -First 1
$server = Get-VBRServer -Name "ESXi Host IP"
$creds = Get-VBRCredentials -Entity $server
Start-VBRRestoreVM –RestorePoint $restorepoint –Server $server -VMName "SFTP 2" -Credentials $creds –PowerUp $false
Disconnect-VBRServer
The script fails on the final cmdlet:
Start-VBRRestoreVM : Failed to login to "ESXi Host IP", port 443, user "root", proxy srv: port:0
At line:1 char:1
+ Start-VBRRestoreVM –RestorePoint $restorepoint –Server $server -VMNam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-VBRRestoreVM], Exception
+ FullyQualifiedErrorId : System.Exception,Veeam.Backup.PowerShell.Cmdlets.StartVBRRestoreVM
Mildur
Product Manager
Posts: 8735
Liked: 2294 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Restore VM to Different Host

Post by Mildur »

Hi SLOCOE Tech

The error message doesn't say much else than login failed.
Have you checked the ESXI logs why the login failed?
Did you have opened a case already with our support? Please provide the case number.

Best,
Fabian
Product Management Analyst @ Veeam Software
tech@SLOCOE.ORG
Novice
Posts: 3
Liked: never
Joined: May 11, 2023 5:23 pm
Full Name: SLOCOE Tech
Contact:

Re: Restore VM to Different Host

Post by tech@SLOCOE.ORG »

I have a case open about PowerShell but I was told that there is no direct support.
Mildur
Product Manager
Posts: 8735
Liked: 2294 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Restore VM to Different Host

Post by Mildur »

Hi SLOCOE Tech

That's correct, we don't support private scripts.
But if you are using a default Veeam Command and it throws an error, then you should be able to get support.

Can you please try the Start-VBRRestoreVM command without using the credentials parameter?
The credentials should not be required in that step:

Code: Select all

Start-VBRRestoreVM –RestorePoint $restorepoint –Server $server -VMName "SFTP 2" –PowerUp $false
Best,
Fabian
Product Management Analyst @ Veeam Software
ronnmartin61
Veeam Software
Posts: 441
Liked: 131 times
Joined: Mar 07, 2016 3:55 pm
Full Name: Ronn Martin
Contact:

Re: Restore VM to Different Host

Post by ronnmartin61 »

From what I can see the -Entity switch wants an array not an standalone string. Also Start-VBRRestoreVM wants the ESXi name not ID so something like the following should fix the issue

Code: Select all

$server = @()
$svr=  Get-VBRServer -Name "192.168.15.11"
$server = $server + $svr
$creds = Get-VBRCredentials -Entity $server
Start-VBRRestoreVM –RestorePoint $restorepoint –Server $server[0].Name -VMName "SFTP 2" -Credentials $creds –PowerUp $false
tech@SLOCOE.ORG
Novice
Posts: 3
Liked: never
Joined: May 11, 2023 5:23 pm
Full Name: SLOCOE Tech
Contact:

Re: Restore VM to Different Host

Post by tech@SLOCOE.ORG »

I am getting the same error with any combination of the suggested changes.
david.domask
Veeam Software
Posts: 1226
Liked: 322 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Restore VM to Different Host

Post by david.domask »

Hi =@tech@SLOCOE.ORG (your user name is like bobby drop tables for phpBB btw :D :D it just breaks the mention functionality a little, not really a problem but funny :) )

I cannot reproduce; drop the -Credentials flag, I don't think you need it at all. That's for connecting to some GuestVM (I'm actually not clear from the docs what it exactly is authenticating with, but you don't need to provide credentials to the ESXi host as it presumably is already added to Veeam and we just will use the credentials that were used to add it.

When you specify -Server, you need to specify resource pools (if applicable) and also the -DataStore and -Folder flag. Else Veeam tries to "guess" the best place to put it.

Try this:

1. Make a dummy VM with empty disks
2. Back it up
3. Try

Start-VBRRestoreVM -RestorePoint $YourRPVariable -ToOriginalLocation

Does it work or fail? For me it worked just fine, same with to another location.

If it fails, please get fresh logs from the VBR server and update the case; mention specifically that it's not the script that's the focus, but the ESXi login issue from the restore logs. It's possible the Powershell parameters are set wrong and pointing to a location the esxi service account cannot access, but log review will tell us what happened with the restore.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests