PowerShell script exchange
Post Reply
DavidCole
Novice
Posts: 4
Liked: never
Joined: Nov 06, 2012 9:52 pm
Full Name: David Cole
Contact:

Error: Failed to register VM (from scripted restore)

Post by DavidCole »

Now that I have been put on the right track for getting my script to know what VMs are available to be restored I have found a new problem. The VM fails to register. The full error is:
Failed to register VM, configFile '[datastore] ServerName/ServerName.vmx', name 'ServerName', isTemplate 'False', poolRef '', hostRef 'host-83', folderRef 'group-v22'
The object has already been deleted or has not been completely created
When I do the same restore from the GUI it works fine, so I'm suspecting there is something somewhat obvious I'm missing. I did a couple of searches in the forum and didn't see a similar error except when folks were changing versions of ESXi, which I'm not doing.

Here's my script as it stands

Code: Select all

Add-PSSnapin -Name VeeamPSSnapin

# Set your variables like a good boy
$sRestoreDatastore = ""
$sRestoreHostFullName = ""
$sRestorePoint = ""
$sRestoreReason = ""
$sRestoreServer = ""
$sVM = ""

# First remind Veeam what is there to be restored
Get-VBRBackupRepository -Name Veeam | Sync-VBRBackupRepository

# Set the variables
$sRestoreVMName = "VM_Name"
$sRestoreHost = "Host_Name"
$sRestoreResourcePool = "Production"
$sRestoreDatastoreName = "Datastore_Name"

# Now get the details that Veeam needs
$sRestorePoint = Get-VBRRestorePoint –Backup(Get-VBRBackup) –Name $sRestoreVMName | select –Last 1
$sRestoreServer = Get-VBRServer -Name $sRestoreHost
$sRestoreDatastore = Find-VBRViDatastore -Server $sRestoreServer -Name $sRestoreDatastoreName

# and now do the restore	
Start-VBRRestoreVM -RestorePoint $sRestorePoint -Server $sRestoreServer	`
	-Datastore $sRestoreDatastore -ResourcePool $sRestoreResourcePool `
	-VMName $sRestoreVMName -Reason "Scripted restore" -PowerUp:$False
Does anyone have any suggestions for solutions or troubleshooting?

Best regards,

D
tsightler
VP, Product Management
Posts: 6035
Liked: 2860 times
Joined: Jun 05, 2009 12:57 pm
Full Name: Tom Sightler
Contact:

Re: Error: Failed to register VM (from scripted restore)

Post by tsightler »

One thing that jumps out to me, the "-ResourcePool" option does not take a string, but rather needs a resource pool object located with Find-VBRViResourcePool so you might try the following changes to your script:

Code: Select all

# Set the variables
$sRestoreVMName = "VM_Name"
$sRestoreHost = "Host_Name"
$sRestoreResourcePoolName = "Production"
$sRestoreDatastoreName = "Datastore_Name"

# Now get the details that Veeam needs
$sRestorePoint = Get-VBRRestorePoint –Backup(Get-VBRBackup) –Name $sRestoreVMName | select –Last 1
$sRestoreServer = Get-VBRServer -Name $sRestoreHost
$sRestoreDatastore = Find-VBRViDatastore -Server $sRestoreServer -Name $sRestoreDatastoreName
$sRestoreResourcePool = Find-VBRViResourcePool -Server $sRestoreServer -Name $sRestoreResourcePoolName

# and now do the restore   
Start-VBRRestoreVM -RestorePoint $sRestorePoint -Server $sRestoreServer   `
   -Datastore $sRestoreDatastore -ResourcePool $sRestoreResourcePool `
   -VMName $sRestoreVMName -Reason "Scripted restore" -PowerUp:$False
veremin
Product Manager
Posts: 20406
Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Error: Failed to register VM (from scripted restore)

Post by veremin »

Just a little note - please be aware that Find-VBRViResourcePool doesn’t seem to work in case of vCenter. That’s to say, if you tried to specify you vCenter as a “–server” parameter, the abovementioned method wouldn’t find any. So, it’s a host that needs to be specified.

Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests