Virtual Machines (VMs) can be added to the vSphere Inventory in vCenter Server/ Virtual Center or in an ESX/ESXi from GUI or command line of the ESX/ ESXi host.
To register a virtual machine in vCenter Server:
- Log in to vSphere Web Client (Flex/Flash or HTML5).
- Click on the desired host.
- Click the Datastores tab
- Click on the appropriate datastore
- Click on the Files tab
- Locate the correct directory for the VM and double-click it to open the folder
- Locate the
virtual machine.vmx
file and click on it to highlight it.
- Click the "Register VM" button
- If using the Flex/Flash client, right-click the VMX file and then select "Register VM"
- Continue to follow the wizard to add the virtual machine.
To register a virtual machine from the command line in an ESXi host:
- Log in as root to the ESXi host with an SSH client. For more information about enabling SSH on an ESXi host, see Using ESXi Shell in ESXi 5.x, 6.x and 7.x
- Run the command:
# vim-cmd solo/registervm /vmfs/volumes/datastore_name/VM_directory/VM_name.vmx
To unregister a virtual machine in vCenter Server:
- Log in to vSphere Web Client (Flex/Flash or HTML5).
- Power off the virtual machine.
- Right click on the virtual machine and select "Remove from inventory".
To unregister a virtual machine from the command line in an ESXi host:
- Log in as root to the ESXi host with an SSH client. For more information about enabling SSH on an ESXi host, see Using ESXi Shell in ESXi 5.x, 6.x and 7.x
- Obtain the VM's VM ID by running vim-cmd vmsvc/getallvms and looking at the leftmost column.
- Run the command:
# vim-cmd
vmsvc/getallvms | grep <vm_name>
# vim-cmd
vmsvc/unregister <VM ID>