PowerShell script exchange
Post Reply
amedjber
Influencer
Posts: 13
Liked: 1 time
Joined: Jun 23, 2022 1:59 pm
Full Name: MEDJBER Assalas
Contact:

Restore VM into GCP via PowerShell

Post by amedjber »

Hi,

I'm a student from France trying to restore a VM from Veeam Backup & Replication to GCP by using a PowerShell script, aiming to automate this task in the future.
I found a script on youtube of a person doing exactly what I'm looking for, so I tried to understand the script and copied it with my values.

I had first many errors, that I debugged step by step. I'm now like "blocked" with an error that I don't understand :

Code: Select all

Start-VBRVMRestoreToGoogleCloud : Cannot validate argument on parameter 'RestorePoint'. The argument is null. Provide a valid value for the argument, 
and then try running the command again.
At C:\Users\sa_veeam\Documents\Test script.ps1:12 char:47
+ Start-VBRVMRestoreToGoogleCloud -RestorePoint $restorepoint -Zone $gc ...
+                                               ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Start-VBRVMRestoreToGoogleCloud], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.StartVBRVMRestoreToGoogleCloud

Here is my PowerShell script :

Code: Select all

$gcpaccount = Get-VBRGoogleCloudComputeAccount -Name "xxxxxx"
$gcpregion = Get-VBRGoogleCloudComputeRegion -Account $gcpaccount -Name "europe-west1"
$gcpzone = Get-VBRGoogleCloudComputeZone -Region $gcpregion -Name "europe-west1-b"
$gcptype = Get-VBRGoogleCloudComputeInstanceType -Zone $gcpzone -Name "e2-small"
$gcpvpc = Get-VBRGoogleCloudComputeVPC -Account $gcpaccount -Name "default"
$gcpsubnet = Get-VBRGoogleCloudComputeSubnet -VPC $gcpvpc -Region $gcpregion -Name "default"
$restorepoint = Get-VBRRestorePoint -Name "xxxxxxx" | Sort-Object $_.creationtime -Descending | Select -First 1
$gcpdisk = New-VBRGoogleCloudComputeDiskConfiguration -Diskname "xxxxxx.vmdk" -DiskType StandardPersistent
$gcprestoredVMname = "testRestoredVM"
$gcpproxy = New-VBRGoogleCloudComputeProxyAppliance -InstanceType $gcptype -RedirectorPort 443 -Subnet $gcpsubnet
Start-VBRVMRestoreToGoogleCloud -RestorePoint $restorepoint -Zone $gcpzone -InstanceType $gcptype -VMName $gcprestoredVMName -Subnet $gcpsubnet -DiskConfiguration $gcpdisk -ProxyAppliance $gcpproxy -AllocatePublicIP
Thank you for your help !! :)
Mildur
Product Manager
Posts: 9846
Liked: 2607 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Restore VM into GCP via PowerShell

Post by Mildur »

Hi Medjber

Welcome to the forum.
Seems to me like the variable $restorepoint is empty.
Can you see a restore Point when you run only the following command:

Code: Select all

Get-VBRRestorePoint -Name "xxxxxxx" | Sort-Object $_.creationtime -Descending | Select -First 1
Thanks
Fabian
Product Management Analyst @ Veeam Software
amedjber
Influencer
Posts: 13
Liked: 1 time
Joined: Jun 23, 2022 1:59 pm
Full Name: MEDJBER Assalas
Contact:

Re: Restore VM into GCP via PowerShell

Post by amedjber »

Hi Fabian,

Thank you for trying to help me !
Indeed, when I run the command alone, nothing result to it.
However, I do have content registered in my variable, right? With this line : $restorepoint = Get-VBRRestorePoint -Name "xxxxxxx" | Sort-Object $_.creationtime -Descending | Select -First 1

I'm a PowerShell beginner, sorry if something looking obvious for you isn't for me :(

Amedjber

EDIT :

This is the video I used to have a solid base for the script : https://www.youtube.com/watch?v=P2yshoK ... ewZhelezko
The script is visible around 3:40mn
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Restore VM into GCP via PowerShell

Post by oleg.feoktistov »

Hi,

If you run the command and get no output, nothing will also be assigned to a variable if you add one.
I would advise to check the filtering criterias for your restore points. Might be something to do with Name filter, for example.
Try running the cmdlet without sort and select expressions, then if doesn't work adjust name criteria and etc.

Thanks,
Oleg
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 5 guests