PowerShell script exchange
Post Reply
dbr
Enthusiast
Posts: 96
Liked: 8 times
Joined: Apr 06, 2017 9:48 am
Full Name: Daniel Brase
Contact:

Creating virtual lab through powershell

Post by dbr »

Hi guys,

since scripting is not covered by support policy I have no case ID.

Because my virtual lab configuration crashed several times and I had to create some labs from scratch, I want to start scripting my virtual lab configuration. I've awaited virtual lab scripting a long time and with version 10 it's available. If I run Add-VBRViAdvancedVirtualLab I get an error:

Code: Select all

Add-VBRViAdvancedVirtualLab -Name $name -Server $esx -CacheDatastore $datastore -ProxyAppliance $appliance -NetworkOptions $networkoptions -NetworkMappingRule $mapping -EnableRoutingBetweenvNics -IpMappingRule $staticmapping -Force

Add-VBRViAdvancedVirtualLab : Object reference not set to an instance of an object.
At line:1 char:1
+ Add-VBRViAdvancedVirtualLab -Name $name -Server $esx -CacheDatastore  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-VBRViAdvancedVirtualLab], NullReferenceException
    + FullyQualifiedErrorId : System.NullReferenceException,Veeam.Backup.PowerShell.Cmdlets.AddVBRViAdvancedVirtualLab
Comparing to the configuration in the gui I even don't understand the difference between NetworkOptions and NetworkMappingRule respectively when the one or the other is used. If NetworkOptions is omitted I get the same error If -NetworkMappingRule is omitted the error is "Add-VBRViAdvancedVirtualLab : Specify NetworkMappingRule parameter." even though the parameter isn't mandatory. Can someone shed some light on this or does someone have an idea how to narrow down the issue?

Thanks, Daniel.

jhoughes
Veeam Software
Posts: 260
Liked: 105 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Austin, TX
Contact:

Re: Creating virtual lab through powershell

Post by jhoughes »

We need your entire script to see what you are running to set your variables. Also, you should verify that each variable has a value, as the 'NullReferenceException' typically means that one of your variables is null.

Here's a sample of where I created a virtual lab as a demo for VeeamON:
https://github.com/jhoughes/VeeamON2020 ... mation.ps1
Husband, Father, Solutions Architect, Geek Extraordinaire | @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion

dbr
Enthusiast
Posts: 96
Liked: 8 times
Joined: Apr 06, 2017 9:48 am
Full Name: Daniel Brase
Contact:

Re: Creating virtual lab through powershell

Post by dbr »

Hi Joe,

The variables are all filled with the correct object types. I understand that troubleshooting an one line without the rest of the script is hard, but I hoped I would get an answer like your's. At first glance your scripts look incredible! I will trash my temporary one and will use your's as template and try again. Thanks for the hint.

Can you clarify when to use the parameters NetworkOptions and NetworkMappingRule, anyway? I'm confused because the NetworkMappingRule parameter expects an object created by New-VBRViNetworkMappingRule and NetworkOptions expects an object by New-VBRViVirtualLabNetworkOptions which also expects an object created by New-VBRViNetworkMappingRule as parameter NetworkMappingRule. Here a hierarchical view of what I mean:

NetworkMappingRule (New-VBRViNetworkMappingRule)
-- Server
-- ProductionNetwork
-- IsolatedNetworkName
-- VLANID

NetworkOptions (New-VBRViVirtualLabNetworkOptions)
-- NetworkMappingRule (New-VBRViNetworkMappingRule)
---- Server
---- ProductionNetwork
---- IsolatedNetworkName
---- VLANID
-- IPAddress
-- SubnetMask
-- MasqueradeIPAddress
-- DNSServer
-- EnableDHCP

dbr
Enthusiast
Posts: 96
Liked: 8 times
Joined: Apr 06, 2017 9:48 am
Full Name: Daniel Brase
Contact:

Re: Creating virtual lab through powershell

Post by dbr »

Hi Joe,

Regarding the main issue: I don't know exactly what caused the issue, but I edited your script to fit my needs and could get the lab creation working. Nice Work. Thanks a lot again!

dbr
Enthusiast
Posts: 96
Liked: 8 times
Joined: Apr 06, 2017 9:48 am
Full Name: Daniel Brase
Contact:

Re: Creating virtual lab through powershell

Post by dbr »

@jhoughes

Today I tried to run my modified script to create the lab again. But it doesn't work anymore. The only difference I see is that meanwhile I upgraded to VBR11 and I know Veeam powershell has been switched from snapin to module. I'm sure that this script worked before, I modified it neither after running it once nor after upgrading to VBR11 . Can you please try to create a virtual lab with your script within a VBR11 environment? Sure, it can also be a change in VMware environment, but as I know there wasn't one and I just want to rule out that this issue is related to the VBR upgrade and changes in Veeam powershell.

Error message:

Code: Select all

Add-VBRViAdvancedVirtualLab : Cannot resolve provided network for proxy appliance.
At C:\Scripts\virtuallab\Untitled99.ps1:82 char:15
+ ... irtualLab = Add-VBRViAdvancedVirtualLab -Server $DestinationServer -N ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Add-VBRViAdvancedVirtualLab], Exception
    + FullyQualifiedErrorId : ErrorSetProxyApplianceOptions,Veeam.Backup.PowerShell.Cmdlets.AddVBRViAdvancedVirtualLab
I found this in the powershell logs:

Code: Select all

[17.03.2021 16:31:35] <18> Warning      There are no valid port groups for host host-686929
[17.03.2021 16:31:35] <18> Error        Cannot resolve production network for <removed for privacy>.
[17.03.2021 16:31:35] <18> Error        There are no valid port groups for host host-686929 (System.Exception)
[17.03.2021 16:31:35] <18> Error           at Veeam.Backup.Core.CNetworkFinder.GetDefaultPortGroup(ISoapConnectionBase conn, String hostRef)
[17.03.2021 16:31:35] <18> Error           at Veeam.Backup.SureBackup.CProxyApplianceConnectionToProductionNetworkOptionsResolver.Resolve()
[17.03.2021 16:31:35] <18> Info         Validating VMware server '<removed for privacy>' (ID: '<removed for privacy>').
[17.03.2021 16:31:36] <18> Warning      [Soap] GetManagementServerIp call is valid only for standalone ESX with API version 2.5 or grater.
ESX-Host is running version 6.7.0, build 17098360.

Thanks in advance,
Daniel

PS: There's a typo in the error message: "ESX with API version 2.5 or grater."

dbr
Enthusiast
Posts: 96
Liked: 8 times
Joined: Apr 06, 2017 9:48 am
Full Name: Daniel Brase
Contact:

Re: Creating virtual lab through powershell

Post by dbr »

Even though powershell is not covered by support policy, I was able to create a support case: 04712560.

PS: You can ignore the warning ...GetManagementServerIp..., it was in the logs prior to update to VBR 11, too.

oleg.feoktistov
Veeam Software
Posts: 847
Liked: 297 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Creating virtual lab through powershell

Post by oleg.feoktistov »

Hi Daniel,

It rather looks like infrastructure-related issue to me. Have you tried to create a lab with the same configs through UI to see if it works?

Thanks,
Oleg

dbr
Enthusiast
Posts: 96
Liked: 8 times
Joined: Apr 06, 2017 9:48 am
Full Name: Daniel Brase
Contact:

Re: Creating virtual lab through powershell

Post by dbr »

Yes, I did. It works without issues. Even though neither the VMware infrastructure nor the scripts have change since before upgrading to VBR 11, I will check my script step by step to see whether a variable is not set correctly or anything else. I will come back with my findings afterwards.

Thanks, Daniel.

dbr
Enthusiast
Posts: 96
Liked: 8 times
Joined: Apr 06, 2017 9:48 am
Full Name: Daniel Brase
Contact:

Re: Creating virtual lab through powershell

Post by dbr »

Hi Oleg,

to rule out any other changes I installed a fresh VBR10 environment, no server no jobs, just an empty installation with a connection to our VMware environment only. My script works perfectly and the virtual lab has been created. After upgrade to VBR11 I removed the "add-pssnapin veeampssnapin" command because of the switch from snapin to modules. I ran the script again and the error occurs. Support said if it works via the gui, then it is probably related to the script. How can it be related to the script if nothing (except add-pssnapin) has changed? As above, Powershell logs say there are no valid ports groups. We only use standard switches instead of dvs ones, but that shouldn't matter because I'm able to the lab via gui. Any further ideas?

Daniel

jhoughes
Veeam Software
Posts: 260
Liked: 105 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Austin, TX
Contact:

Re: Creating virtual lab through powershell

Post by jhoughes »

I only use DVS so haven't tested VSS, but I'll try to get to it in my lab later to confirm on v11.
Husband, Father, Solutions Architect, Geek Extraordinaire | @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion

dbr
Enthusiast
Posts: 96
Liked: 8 times
Joined: Apr 06, 2017 9:48 am
Full Name: Daniel Brase
Contact:

Re: Creating virtual lab through powershell

Post by dbr »

Hi Joe,

Were you able to check with standard switches? Meanwhile I tested with vCenter version 7.0.1 build 17491160 and another destination esx host with version 6.5.0 build 17167537 with no success.

Daniel

oleg.feoktistov
Veeam Software
Posts: 847
Liked: 297 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Creating virtual lab through powershell

Post by oleg.feoktistov »

Hi Daniel,

I've managed to duly test clean installation of the virtual lab with all the parameters you used in the environment with vCenter v6.5 and destination Esxi v6.5. I could create the lab with the same parameters from both the UI and Powershell. I also checked the backend code for "Cannot resolve provided network for proxy appliance." error. The logic behind that is clear - we search for the first occurrence of a network specified in New-VBRViVirtualLabProxyAppliance cmdlet in an array of all networks received from vCenter/Esxi to revalidate that the production network you want to connect your proxy to exists. If we don't find one, we exit with the exception you see. I'd suggest to keep working with the support and also share the updates here.

Thanks,
Oleg

dbr
Enthusiast
Posts: 96
Liked: 8 times
Joined: Apr 06, 2017 9:48 am
Full Name: Daniel Brase
Contact:

Re: Creating virtual lab through powershell

Post by dbr »

Hi Oleg,

thanks for investigating. I'm still in contact with tier 2 support and we will have a session tomorrow. I will come back with the findings here.

Daniel

oleg.feoktistov
Veeam Software
Posts: 847
Liked: 297 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Creating virtual lab through powershell

Post by oleg.feoktistov »

Hi Daniel,

Thanks. I’ll also keep tracking your case from product management side.

Best regards,
Oleg

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests