I did some searching and it seems like it can be done. I want to be able to add hosts to my exsisting enviroment, but I do not want to manually have to create all the vswitches and portgroups. Is there a way, without using a template to collect the vswitch info from a host and apply that to the new host so everything is created on the fly? Perhaps export vswitch config information and import into a new host but being able to change the IP? Thanks in advance.
Everything is possible, but I'm afraid a simple export/import won't do the trick.
You're in fact trying to do part of what the Host Profile is doing.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Would I be better off then just trying to create a host profile? The main goal is to create the second vswitch and assign it an IP based off of the management IP address. For instance, if my host address is 192.168.110.55, I would like the second vswitch to have an address of 192.168.150.55. I was hoping to be able to do this without providing the information. I assume there is not a way to capture the IP of the host, and then change the 3rd octet to a certain number and apply that address to the second nic?
The problem here, as I see it, is that the current PowerCLI cmdlet for working with Host Profiles are a bit of an all-or-nothing setup.
With the SDK methods on the other hand it looks as if it's possible to apply parts of a host profile. See the HostApplyProfile object.
In your case that would be the vSwitch and portgroup configuration under network.
I'll investigate this further.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I found a work around, but I do appreciate all your help. Using the code below, I just broke the host IP address out into an array. I then changed the array value that held the third octet information to what i needed it to be, and I then reassembled the address. This works in my case because I only need to change one octet.
I will look into what you provided though, because that seems to be the correct way of doing things.
$currenthost = "192.168.120.55" $octet = $currentHost.split(".") $octet[2] = 150 $IP = $octet[0] + "." + $octet[1] + "." + $octet[2] + "." + $octet[3]