VMware Cloud Community
esxi1979
Expert
Expert
Jump to solution

bulk add vmkernel to esxi

Hello

I need to bulk add vmkernel ports to esxi

csv file

esxi mgmt ip /esxi-vmkernel-name/vmkernelIP

can someone help

Thanks

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

# Following info is in the CSV

#

# 'VMHost','Switch','Port','IP','Mask'

# 'esx1','switch1','100','192.168.0.50','255.255.255.0'

#

Import-Csv vmkernel.csv -UseCulture | %{

    $myVMHost = Get-VMHost -Name $_.VMHost

    $myVDSwitch = Get-VDSwitch -Name $_.Switch

    New-VMHostNetworkAdapter -VMHost $myVMHost -VirtualSwitch $myVDSwitch -PortId $_.Port -IP $_.IP -SubnetMask $_.Mask

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

This can easily be done with the New-VMHostNetworkAdapter cmdlet,

But you need more information in the CSV, like for example the vSwitch where the VMKernel needs to be created.

Can you perhaps show us some sample lines from the CSV you will be using?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
esxi1979
Expert
Expert
Jump to solution

my case is

Creates a new VMKernel network adapter and connects it to the specified port group on the specified distributed switch.

-------------- Example 8 --------------

$myVMHost = Get-VMHost -Name "MyVMHost"

$myVDSwitch = Get-VDSwitch -Name "MyVDSwitch"

New-VMHostNetworkAdapter -VMHost $myVMHost -VirtualSwitch $myVDSwitch -PortId 100 -IP 192.168.0.50 -SubnetMask 255.255.255.0

So here the ip will be specific for each node ..

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this

# Following info is in the CSV

#

# 'VMHost','Switch','Port','IP','Mask'

# 'esx1','switch1','100','192.168.0.50','255.255.255.0'

#

Import-Csv vmkernel.csv -UseCulture | %{

    $myVMHost = Get-VMHost -Name $_.VMHost

    $myVDSwitch = Get-VDSwitch -Name $_.Switch

    New-VMHostNetworkAdapter -VMHost $myVMHost -VirtualSwitch $myVDSwitch -PortId $_.Port -IP $_.IP -SubnetMask $_.Mask

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos