rumyyy
Contributor
Contributor

Get list of available USB devices connected to ESXi host in PowerCLI.

Jump to solution

Hi guys,

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.

1 Solution

Accepted Solutions
pwilk
Hot Shot
Hot Shot

And what if you run ESXi shell commands through SSH connection from Jenkins? This way you could bypass PowerCLI and still run these tests.

Cheers, Paul Wilk

View solution in original post

0 Kudos
13 Replies
pwilk
Hot Shot
Hot Shot

Have you seen this doc? Get-UsbDevice

Cheers, Paul Wilk
0 Kudos
rumyyy
Contributor
Contributor

Yes, that gives you the devices that have been connected to a specific virtual machine. What I need is the list of devices that are available to connect to.

0 Kudos
pwilk
Hot Shot
Hot Shot

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?

Cheers, Paul Wilk
0 Kudos
rumyyy
Contributor
Contributor

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.

0 Kudos
rumyyy
Contributor
Contributor

Ideally, I want the connection to the USB devices to be foolproof in order to avoid any failure.

0 Kudos
rumyyy
Contributor
Contributor

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.

0 Kudos
pwilk
Hot Shot
Hot Shot

And what if you run ESXi shell commands through SSH connection from Jenkins? This way you could bypass PowerCLI and still run these tests.

Cheers, Paul Wilk
0 Kudos
rumyyy
Contributor
Contributor

That's an option I considered, but will I be able to start/stop/revert/delete VM from the ESXi Shell?

0 Kudos
pwilk
Hot Shot
Hot Shot

ESXi shell:

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

Cheers, Paul Wilk
0 Kudos
rumyyy
Contributor
Contributor

Thank you very much!

0 Kudos
pwilk
Hot Shot
Hot Shot

You are very welcome my Linux friend Smiley Wink

Please let me know if you'd any further assistance

Cheers, Paul Wilk
0 Kudos
rumyyy
Contributor
Contributor

And do you know where I can find the commands for connecting disconnecting a USB device using ESXi shell

0 Kudos
pwilk
Hot Shot
Hot Shot

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...

Cheers, Paul Wilk