I have an AHV VM that I would like to disconnect the NIC and connect the NIC in my script. I need it disconnected while sysprep runs and sets a static IP address then I’m good to connect the NIC again. (Otherwise it pulls a DHCP address and replaced the hostname with the DHCP address in DNS).
I can Get-NTNXVMNIC and see the current status of the NIC but I don’t see a way to change the status (i.e. I don’t find a Set-NTNXVMNIC command).
Best answer by TimGarayView original
I tried removing the NIC and then adding the NIC with “isConnected = False” in the VMNicSpecDTO but it still started up as connected.
I did figure out that I wasn’t actually deleting the VMNIC like I thought. The -Nicid parameter is actually looking for the MAC address. Once I used that then I could delete the NIC. Of course, when you remove the NIC and then add a new one to it then that changes the MAC address.
I managed to do this “the hard way” by using REST API.
Failing to execute Set-NTNXVMPowerState from PoSH Script - access denied
leepryor / Nutanix_Powershell
It then returns the task_uuid and you can see in the web GUI the status of the task.
Another big help was the “REST API Explorer Live!” in the web GUI.
I can use this for now but I would really like to see a “Set-NTNXVMNIC” cmdlet in future releases.