WilliamLam.com

  • About
    • About
    • Privacy
  • VMware Cloud Foundation
  • VKS
  • Homelab
    • Hardware Options
    • Hardware Reviews
    • Lab Deployment Scripts
    • Nested Virtualization
    • Homelab Podcasts
  • VMware Nostalgia
  • Apple

Quick Tip - Audit vSphere VMs configured with USB Controllers

03.07.2024 by William Lam // 6 Comments

Automation scales Operations, that is a phrase that I have used several times today in various conversations with colleagues and customers. I truly believe organizations can scale more efficiently and consistently when leveraging Automation and not be afraid of it or worse, attempting to avoid it at all cost!

In fact, Automation is a super power when it comes to the various reporting and auditing needs of an organization such as this recent inquiry in auditing all vSphere VMs that have been configured with a USB controller. The following PowerCLI snippet leverages  the vSphere API to check whether there are any VMs that have been configured with either a USB 2.x controller (VirtualUSBController) or USB 3.x controller (VirtualUSBXHCIController) and outputs that in a simple table format, as shown in the example below.

# Retrieve all VMs and only include Name and Device data
$vms = Get-View -ViewType VirtualMachine -Property Name,Config.Hardware.Device

$results = @()
foreach ($vm in $vms) {
    $haveUSB2Controller = $false
    $haveUSB3Controller = $false

    # Filter out devices that have USB 2.x and 3.x controllers & USB Devices (for mapping purposes)
    $devices = $vm.Config.Hardware.Device | where {$_.getType().Name -eq "VirtualUSBController" -or $_.getType().Name -eq "VirtualUSBXHCIController" -or $_.getType().Name -eq "VirtualUSB"}

    $usb2devices = @()
    $usb3devices = @()
    foreach ($device in $devices) {
        # Check whether USB controller is 2.x
        if($device.getType().Name -eq "VirtualUSBController") {
            $haveUSB2Controller = $true

            # Collect any connected USB devices on this controller
            foreach ($deviceKey in $device.device) {
                $usbDevice = $devices | where {$_.key -eq $deviceKey}
                $usbVid = [String]::Format("{0:x}", $usbDevice.Vendor)
                $usbPid = [String]::Format("{0:x}", $usbDevice.Product)
                $usb2devices += "${usbVid}:${usbPid}"
            }
        }

        # Check whether USB controller is 3.x
        if($device.getType().Name -eq "VirtualUSBXHCIController") {
            $haveUSB3Controller = $true

            # Collect any connected USB devices on this controller
            foreach ($deviceKey in $device.device) {
                $usbDevice = $devices | where {$_.key -eq $deviceKey}
                $usbVid = [String]::Format("{0:x}", $usbDevice.Vendor)
                $usbPid = [String]::Format("{0:x}", $usbDevice.Product)
                $usb3devices += "${usbVid}:${usbPid}"
            }
        }
    }
    # Only output VMs that have USB controllers
    if($haveUSB2Controller -or $haveUSB3Controller) {
        $tmp = [pscustomobject] @{
            VM = $vm.Name
            USB2Controller = $haveUSB2Controller
            USB2Devices = $usb2devices
            USB3Controller = $haveUSB3Controller
            USB3Devices = $usb3devices
        }
        $results+=$tmp
    }
}

# Format output (can easily output to CSV/Excel)
$results | ft

Here is an example screenshot listing only the VMs that have a USB controller and you can easily pipe the output to CSV or Excel for further processing rather than displaying the results in the console.

UPDATE (03/11/24) - The script above has been updated to also included all connected USB devices for either USB 2.x or 3.x controller found for a given VM. The format of the connected USB devices are vendorId:productId, which you can then use sites like DeviceHunt to get the friendly vendor/product name.

Categories // Automation, PowerCLI Tags // usb

Quick Tip - Using ESXCLI to upgrade ESXi 8.x throws MemoryError or Got no data from process

03.04.2024 by William Lam // 28 Comments

Several users in the community have reported running into a memory error issue when attempting to upgrade their standalone ESXi hosts using this ESXCLI trick, which has been possible since ESXi 5.1 back in 2012.

[MemoryError]
Please refer to the log file for more details.


Initially, I was not able to reproduce in my lab environment at work, which was running ESXi 8.0 Update 2, but I still got an error message but it was different:

Got no data from process.
Command "LANG=en_US.UTF-8 /usr/lib/vmware/esxcli-software sources.profile.list -d "https://hostupdate.vmware.com/software/VUM/PRODUCTION/main/vmw-depot-index.xml" "
еxited with error code: 1


After checking my homelab environment which was also running ESXi 8.0 Update 2, I did see the same MemoryError message as reported by the community when using ESXCLI to list the available ESXi Image Profiles from VMware's online patch repository.

[Read more...]

Categories // Automation, ESXi Tags // esxcli

Determining new VMware vSphere Foundation (VVF) & VMware Cloud Foundation (VCF) license usage in vSphere 8.0 Update 2b

03.04.2024 by William Lam // 14 Comments

vSphere 8.0 Update 2b was just released last week and with this release, customers can now take advantage of the new included 100 GiB trial vSAN storage capacity for each deployed VMware vSphere Foundation (VVF) core for use with vSAN!

Note: If you would like to understand how much vSAN storage you are entitled to (100GiB for VVF and 1TiB for VMware Cloud Foundation (VCF)), check out the new inventory and calculator script in KB 95927 (brownfield) and KB 96426 (greenfield) for more details.

In addition to installing and/or updating your vCenter Server to vSphere 8.0 Update 2b, you will also need to login to Customer Connect to download your new VVF and/or VCF license keys that will activate your vSAN entitlement.

I have already received questions on how to determine whether an ESXi host has been licensed with the new VVF and/or VCF license keys and which you can do so by using the vSphere UI by navigating to Administration->Licensing->Licenses->Assets->Hosts or vSAN Clusters and using the various filters, but this can be time consuming when you have a large environment with various license editions.

This is where automation and vSphere API can help!

[Read more...]

Categories // Automation, VMware Cloud Foundation, VMware vSphere Foundation Tags // VCF, VMware Cloud Foundation, VMware vSphere Foundation, VVF

  • « Previous Page
  • 1
  • …
  • 37
  • 38
  • 39
  • 40
  • 41
  • …
  • 561
  • Next Page »

Search

Thank Author

Author

William is Distinguished Platform Engineering Architect in the VMware Cloud Foundation (VCF) Division at Broadcom. His primary focus is helping customers and partners build, run and operate a modern Private Cloud using the VMware Cloud Foundation (VCF) platform.

Connect

  • Bluesky
  • Email
  • GitHub
  • LinkedIn
  • Mastodon
  • Reddit
  • RSS
  • Twitter
  • Vimeo

Recent

  • Automating the vSAN Data Migration Pre-check using vSAN API 06/04/2025
  • VCF 9.0 Hardware Considerations 05/30/2025
  • VMware Flings is now available in Free Downloads of Broadcom Support Portal (BSP) 05/19/2025
  • VMUG Connect 2025 - Minimal VMware Cloud Foundation (VCF) 5.x in a Box  05/15/2025
  • Programmatically accessing the Broadcom Compatibility Guide (BCG) 05/06/2025

Advertisment

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright WilliamLam.com © 2025

 

Loading Comments...