Here is the code developed -- till now.
I was hoping to change the $x in the for loop so that it would increment the IP by one each time it runs through configuring vmotion nic and ip on a host.
$i = Get-Cluster -Name "NPRDMGMT_CLU" | Get-VMHost
ForEach ($H in $i) {
New-VMHostNetworkAdapter -VMHost $H -PortGroup "VM VMOTION - x.x.x.x" -VirtualSwitch NPRD -VMotionEnabled $true -MTU 1500
$Vmotion = get-vmhostnetworkadapter | where { $_.portgroupname -eq "VM VMOTION - x.x.x.x" }
set-vmhostnetworkadapter -virtualnic $Vmotion -ip x.x.x.$x -SubnetMask x.x.x.0 -Confirm:$false
Get-VMHost $H | Get-VMHostNetworkAdapter -Name vmk1 |Set-VMHostNetworkAdapter -VMotionEnabled $false
}
Try something like this
$i = Get-Cluster -Name "NPRDMGMT_CLU" | Get-VMHost
ForEach ($H in $i) {
New-VMHostNetworkAdapter -VMHost $H -PortGroup "VM VMOTION - x.x.x.x" -VirtualSwitch NPRD -VMotionEnabled $true -MTU 1500
$Vmotion = get-vmhostnetworkadapter | where { $_.portgroupname -eq "VM VMOTION - x.x.x.x" }
set-vmhostnetworkadapter -virtualnic $Vmotion -ip "x.x.x.$($x)" -SubnetMask x.x.x.0 -Confirm:$false
Get-VMHost $H | Get-VMHostNetworkAdapter -Name vmk1 | Set-VMHostNetworkAdapter -VMotionEnabled $false
$x++
}
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
$i = Get-Cluster -Name "NPRDMGMT_CLU" | Get-VMHost
ForEach ($H in $i) {
New-VMHostNetworkAdapter -VMHost $H -PortGroup "VM VMOTION - x.x.x.x" -VirtualSwitch NPRD -VMotionEnabled $true -MTU 1500
$Vmotion = get-vmhostnetworkadapter | where { $_.portgroupname -eq "VM VMOTION - x.x.x.x" }
set-vmhostnetworkadapter -virtualnic $Vmotion -ip "x.x.x.$($x)" -SubnetMask x.x.x.0 -Confirm:$false
Get-VMHost $H | Get-VMHostNetworkAdapter -Name vmk1 | Set-VMHostNetworkAdapter -VMotionEnabled $false
$x++
}
---------------------------------------------------------------------------------------------------------
Was it helpful? Let us know by completing this short survey here.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you for you guidance here. There seems to be a small issue though, the IP did get assign sequentially per host, but at the last iteration all the IPs were updated to one common IP. So you see any issues with the script ?
I don't really understand what you mean.
Could you perhaps show the IP addresses that were used for each ESXi node?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi the issue looked to be the $vmotion variable,
for ($x=0;$x -lt $i.count; $x++)
this line fixed the issue.