I want to Change ESXi managment ip and vlan id for managment network by script/commands at same time.
How to combaine those commands in to one in powershell? without losing connection to host in between commands
Directly connected to host via powershell
$esxcli = Get-VMHost | Get-EsxCli -v2
$esxcliset = $esxcli.network.ip.interface.ipv4.set
$args = $esxcliset.CreateArgs()
$args.interfacename = 'vmk0'
$args.type = 'static'
$args.ipv4 = '192.168.248.136'
$args.netmask = '255.255.255.0'
Get-VMHost | Get-VirtualPortGroup -Name "Management Network" | Set-VirtualPortGroup -Name "Management Network" -VLanID 20
yes. It disconnects as soon as we change IP address. Currently the Esxi is on Trunk port i.e different vlan and IP address i.e (172.17.xx.xx on vlan 1000). we might be getting different vlan and different network (196.168.248.xx on vlan 20).
The current script I am able to execute commands to change IP address but we get trunk port we need to mention the trunk port new vlan ID as well. So I am able to change either IP address or vlan only. Is there any way Where I can change IP address and Vlan as the same time ?
vlan : 1000
Ipaddress : 172.17.xx.xx
2. Required network range Trunk port
vlan : 20
i need to change both at same time without losing connection to the host.
i understand i have to reconnect to new ip once ip changed.