Here is a PowerShell script to list the virtual machines (VMs) on an ESXi host:
#Connect to the ESXi host
Connect-VIServer -Server <ESXi_host_name>
# Get a list of all VMs on the ESXi host
$VMs = Get-VM
# Loop through each VM and display its name and power state
foreach ($VM in $VMs)
{
Write-Host "Name: $($VM.Name), Power State: $($VM.PowerState)"
}
# Disconnect from the ESXi host
Disconnect-VIServer -Server <ESXi_host_name> -Confirm:$false
Note: Replace<ESXi_host_name>
with the actual hostname of the ESXi host