PowerShell script exchange
jevao
Enthusiast
Posts: 29 Liked: 3 times
Joined: Oct 28, 2011 11:38 pm
Full Name: James Collison
Contact:
Post
by jevao » Oct 02, 2014 9:26 pm
this post
I receive the following error when running:
Start-VBRRestoreVM -RestorePoint $RestorePoint -Server $Server -ResourcePool $ResourcePool -Datastore $vmdatastore -VMName $vmsin1
Code: Select all
Start-VBRRestoreVM : Object reference not set to an instance of an object.
At C:\users\veeam\scripts\restorebkups\restorebkups.ps1:75 char:11
+ Start-VBRRestoreVM -RestorePoint $RestorePoint -Server $Server -Resour ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-VBRRestoreVM], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,Veeam.Backup.PowerShell.Command.StartVBRRestoreVM
I used the following to set this up:
Code: Select all
$RestorePoint = Get-VBRRestorePoint -Backup $bkup -Name $vmname-string | sort-object $_.creationtime -Descending | select -first 1
$vmdatastore = find-vbrvidatastore -server spock.das.perforce.com -name $vmds
$ResourcePool = Find-VBRViResourcePool -Server (get-vbrserver -name $servername) | select -last 1
$Server = Get-vbrserver -name $servername
$vmsin1 = "vmname"
Any help would be greatly appreciated.
veremin
Product Manager
Posts: 20400 Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Oct 03, 2014 8:59 am
this post
As first investigation step I would double check whether all variables have been assigned properly. Input variables in PowerShell console and see whether they do contain not null value.
Code: Select all
$RestorePoint
$vmdatastore
$ResourcePool
$Server
$vmsin1
Thanks.
jevao
Enthusiast
Posts: 29 Liked: 3 times
Joined: Oct 28, 2011 11:38 pm
Full Name: James Collison
Contact:
Post
by jevao » Oct 03, 2014 4:55 pm
this post
Thanks for replying.
Yes I did that.
I ran it through the shell and saw the output of each was an object.
The only thing that seemed strange was "get-vbrserver -name" did not return multiple properties in the object,
but just the server name.
Other than that, if I reduce the paramaters to only mandatory parameters, Restorepoint and Server, I still see the error.
jevao
Enthusiast
Posts: 29 Liked: 3 times
Joined: Oct 28, 2011 11:38 pm
Full Name: James Collison
Contact:
Post
by jevao » Oct 03, 2014 5:59 pm
this post
I was trying to restore to a cluster, not a host.
When I changed to restore directly to a host I receive the following error:
Start-VBRRestoreVM : Exception has been thrown by the target of an invocation.
At C:\users\veeam\scripts\restorebkups\restorebk.ps1:64 char:30
+ $tmpRestoreSession = Start-VBRRestoreVM -RestorePoint ($RestorePoint) -S ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Start-VBRRestoreVM], TargetInvocationException
+ FullyQualifiedErrorId : System.Reflection.TargetInvocationException,Veeam.Backup.PowerShell.Command.
StartVBRRestoreVM
jevao
Enthusiast
Posts: 29 Liked: 3 times
Joined: Oct 28, 2011 11:38 pm
Full Name: James Collison
Contact:
Post
by jevao » Oct 03, 2014 6:08 pm
this post
SOLVED:
The "Exception thrown" error was due to not running as Administrator.
Once I did restore from host, rather than cluster, and "Run as Administrator" on console2,
then it worked fine.
Thanks much for your help.
veremin
Product Manager
Posts: 20400 Liked: 2298 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:
Post
by veremin » Oct 06, 2014 3:32 pm
this post
Yes, that was the second question that I was going to ask - whether or nor the used account has required permissions. Glad that you've nailed it yourself. Thanks.
Users browsing this forum: No registered users and 16 guests