I want to get a list of the available USB devices from vSphere PowerCLI. The devices are connected to my ESXi 6.0 server.
I am able to get the list of devices with 'lsusb' from ESXi Shell.
Also, can I use VendorId or ProductId to connect the USB device to a VM again form PowerCLI.
I don't think what you're trying to accomplish is possible from vSphere level. Have you tried running
tail -f /var/log/vmkernel.log | grep -i USB
from ESXi shell?
If you can get a list of devices using lsusb, why would you insist on using PowerCLI?
I would like to Revert/Start/Stop/Delete VM as well as connect USB devices to them using the PowerCLI, so that I can run these commands from Jenkins. The purpose of all of this is to to run automated tests on these VMs.
I'm considering to make an usb.autoConnect.device in .vmx file of the VM, but I'm afraid this would give errors if another machine is trying to use the same device. The best way is to get the list of available devices in order to know what is available for use.
power on: vim-cmd vmsvc/power.on <vmid>
power off: vim-cmd vmsvc/power.off <vmid>
delete: vim-cmd vmsvc/destroy <vmid>
Here is a list of most common VM-oriented commands in PowerCLI/vMA/ESXi cli VMware Knowledge Base
I suggest reading through this doc to better understand vim-cmd commands. Most operations can be "figured out" after reading this https://communities.vmware.com/servlet/JiveServlet/downloadBody/31025-102-1-44609/Quick%20Tutorial%2...