Using PowerCLI 4.1, is there are way to set the port group connection type (Virtual Machine or VMKernel) when you create the Port Group?
thank you
Ok, try it like this.
$VMHostObj = Get-VMHost $ESXHost $vsw = get-virtualswitch -name vSwitch0 -VMHost $VMHostObj New-VMhostNetworkAdapter -VMHost $VMHostObj -VirtualSwitch $vsw -PortGroup "VMotion" -IP 10.110.40.43 -SubnetMask 255.255.255.0 -VMotionEnabled:$true
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The New-VirtualPortGroup cmdlet can only create Virtual Machine portgroups.
If you want to create a VMKernel or Console portgroup, you have to use the New-VMHostNetworkAdapter cmdlet.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks LucD
I'm using ESXi 4.0
you have pointed me in the right direction however the command (in the form I am using) is not working. Here's what I have tried from the POwerCLI 4.1:
$ESXHost = "servername.domain.local"
Connect-VIServer $ESXHost
$VMHostObj = Get-VMHost $ESXHost
$VMHostObj | get-virtualswitch -name vSwitch0 | New-VMhostNetworkAdapter -PortGroup "VMotion" -IP 10.110.40.43 -VMotionEnabled
I also need to set the VLAN on this portgroup however I did not see an option - at least using this command
thank you
You should be able to use the Set-VirtualPortGroup cmdlet for setting the VLAN.
Set-VirtualPortgroup -Name <portgroupname> -VlanId <vlanid>
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Ok thanks, however I cannot get the initial cmdlet that you provided to work - please see my syntax for New-VMHostNetworkAdapter
thanks again
The -VMotionEnabled parameter is a switch and there is no default value, so you will have to set it to $true explicitely
$ESXHost = "servername.domain.local" Connect-VIServer $ESXHost $VMHostObj = Get-VMHost $ESXHost $VMHostObj | get-virtualswitch -name vSwitch0 | New-VMhostNetworkAdapter -PortGroup "VMotion" -IP 10.110.40.43 -VMotionEnabled:$true
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I am receiving the following error, which looks to be referring to the VMotionEnabled switch
I executed peryour example in this thread
New-VMHostNetworkAdapter : Missing an argument for parameter 'VMotionEnabled'.
Specify a parameter of type 'System.Nullable`1[http://System.Boolean|http://System.Boolean]' and try again.
At line:1 char:127
+ $VMHostObj | get-virtualswitch -name vSwitch0 | New-VMhostNetworkAdapter -Por
tGroup "VMotion" -IP 10.110.40.43 -VMotionEnabled <<<< ;$true
+ CategoryInfo : InvalidArgument: ( ,
ParameterBindingException
+ FullyQualifiedErrorId : MissingArgument,VMware.VimAutomation.ViCore.Cmdl
ets.Commands.Host.NewVMHostNetworkAdapter
That's my mistake. A typo, the semicolon after the switch should be a colon.
I updated the lines above.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks LucD
The VMotion error was cleared up however now it is complaining about my usage of pipelines (I think)
New-VMHostNetworkAdapter : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the iput and its properties do not match any of the parameters that take pipeline input.
At line:1 char:73
+ $VMHostObj | get-virtualswitch -name vSwitch0 | New-VMhostNetworkAdapter <<<<
-PortGroup "VMotion" -IP 10.110.40.43 -VMotionEnabled:$true
+ CategoryInfo : InvalidArgument: (vSwitch0:PSObject) [New-VMHost
NetworkAdapter], ParameterBindingException
+ FullyQualifiedErrorId : InputObjectNotBound,VMware.VimAutomation.ViCore.
Cmdlets.Commands.Host.NewVMHostNetworkAdapter
Ok, try it like this.
$VMHostObj = Get-VMHost $ESXHost $vsw = get-virtualswitch -name vSwitch0 -VMHost $VMHostObj New-VMhostNetworkAdapter -VMHost $VMHostObj -VirtualSwitch $vsw -PortGroup "VMotion" -IP 10.110.40.43 -SubnetMask 255.255.255.0 -VMotionEnabled:$true
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
thanks LucD - that worked!