Hi I'm trying to get a menu listing of all VMs in Hyper-V Host. However I'm getting extra information in my menu list. How can I get rid of it?
'''
  $VMs = @(Get-VM | Select-Object Name)
    $menuIndex = 1
    Write-Host "Select a VM from the list"
    $VMs | foreach {
        Write-Host $menuIndex " - $_";
        $menuIndex += 1;
        }
     $ChosenItem = [int](Read-Host "Please select a Virtual Machine (1 to $($menuIndex-1))")
$VM = $VMs[$ChosenItem-1]
'''
The output of this script gives me extra data I don't want to display. I just need the VM Name.
Instead I get:
1 - @{Name=VirtualMachine1} 2 - @{Name=VirtualMachine2}
I would desire to get the following instead:
1 - VirtualMachine1 2 - VirtulaMachine2
How do I remove the "@{Name=}" portion of the output?
Thank You