VMware Cloud Community
Anand_Nandu
Contributor
Contributor

CLI command to connect\disconnect a VM's NIC

Hi Experts,

Can somebody please help me to understand the VMware CLI command to enable\disable (or connect\disconnect) the network adaptor of a VM (which can be done from vsphere client as shown below)

VM-NIC-connect-setting.jpg

Thanks in advance 🙂

0 Kudos
3 Replies
vembutech1
Hot Shot
Hot Shot

0 Kudos
troybailey
Contributor
Contributor

Hi, Did you ever find an answer to this question?

I need to start the NIC on a virtual machine via CLI since the Vsphere server is down and the VMWare client is unable to edit the Virtual machine.

The network adapter was disable on the Vcenter database server.

Thanks!

0 Kudos
MattHumphreys
Contributor
Contributor

Get-VM ENTERVMNAME | Get-NetworkAdapter -Name "ENTERNETWORKADAPTER" | Set-NetworkAdapter -Connected:$false -StartConnected:$false -Confirm:$false

That should do it, if you want to do it on all adapters on a VM then it would be as follows, this script wont ask for confirmation it will just go ahead and do it.

Get-VM ENTERVMNAME | Get-NetworkAdapter | Set-NetworkAdapter -Connected:$false -StartConnected:$false -Confirm:$false

0 Kudos