I'm a french student, sorry if my english isn't perfect
Since weeks, i'm trying to create a script of which the goal is to restore VMs from a GoogleSheet.
I've already succesfully restored a VM from Veeam B&R based on its name, with this code :
Code: Select all
$gcpaccount = Get-VBRGoogleCloudComputeAccount -Name "XXXXXXX"
$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 "private"
$gcpsubnet = Get-VBRGoogleCloudComputeSubnet -VPC $gcpvpc -Region $gcpregion -Name "subnet-pra-2"
$restorepoint = Get-VBRRestorePoint -Name "XXXXXX" | Sort-Object $_.creationtime -Descending | Select -First 1
$gcpdisk = New-VBRGoogleCloudComputeDiskConfiguration -Diskname '{XXXXXXX}' -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
I succesfully connected Powershell with my Google Sheet, and achieved to get the list of my VMs :
Code: Select all
$conn = Connect-GoogleSheets -AuthScheme OAuthJWT -OAuthJWTCert "C:\Users\sa_veeam\Downloads\gsheets-powershell.json" -OAuthJWTCertType GOOGLEJSON
Select-GoogleSheets -Connection $conn -Table "XXXXX_TEST" -Column @("Nom")
Code: Select all
$conn = Connect-GoogleSheets -AuthScheme OAuthJWT -OAuthJWTCert "C:\Users\sa_veeam\Downloads\gsheets-powershell.json" -OAuthJWTCertType GOOGLEJSON
$servname = Select-GoogleSheets -Connection $conn -Table "XXXXXX" -Column "Nom"
$gcpaccount = Get-VBRGoogleCloudComputeAccount -Name "XXXXXXXXX"
$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 "private"
$gcpsubnet = Get-VBRGoogleCloudComputeSubnet -VPC $gcpvpc -Region $gcpregion -Name "subnet-pra-2"
$restorepoint = Get-VBRRestorePoint -Name "$servname" | Sort-Object $_.creationtime -Descending | Select -First 1
$gcpdisk = New-VBRGoogleCloudComputeDiskConfiguration -Diskname '{XXXXXXXXXXX}' -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
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 line:13 char:47
+ Start-VBRVMRestoreToGoogleCloud -RestorePoint $restorepoint -Zone $gc ...
+ ~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Start-VBRVMRestoreToGoogleCloud], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.StartVBRVMRestoreToGoogleCloud
Thanks a lot