Add VMKernel port to several hosts

      No Comments on Add VMKernel port to several hosts

Who likes to configure VMKs on hosts? A couple is totally fine, a few hundreds is not fun!
Unless…
…We use powercli!!

Code Snippet below:

$esx="my-esx-hostname-"
$switchname="mySwitchName"
$net="192.168.45."
1..100 | foreach {
$num = $_
New-VMHostNetworkAdapter -VMHost (Get-VMHost "$esx$num.vmware.com") -PortGroup Vsan -VirtualSwitch (Get-VDSwitch -name $switchname) -IP "$net$num" -SubnetMask "255.255.255.0" -VsanTrafficEnabled $true
}

In short, i’m giving the esx hostname, while the 1..100 is basically a loop that will complete the ESXI hostname and also the last ip address octet, quite handy isn’t it?
I’m configuring VSAN with non routable IP’s. so obviously this may change in your environments. Adjust at will!

Leave a Reply

Your email address will not be published. Required fields are marked *