Powershell:
$vc = Read-Host "Please specify your VirtualCenter"
Connect-VIServer $vc
$VMHs = Get-VM
$myCol = @()
ForEach ($vmh in $vmhs)
{
$myObj = "" |
Select Name, UUID
$myObj.name = $vmh.name
$myObj.UUID = Get-VM $vmh.name | %{(Get-View $_.Id).config.uuid}
$myCol += $myObj
}
$myCol
Hi,
Is there a way to get VM names, their UUID according to resource pool?
Cheers,
Sanit
Hi Sanit,
You can try below code snippet this will give you VM name, UUID and Resource Pool name.
$vc = Read-Host "Please specify your VirtualCenter" Connect-VIServer $vc $rps = Get-ResourcePool ForEach ($rp in $rps) { $VMHs = Get-VM -Location (Get-ResourcePool -Name $rp.name) $myCol = @() ForEach ($vmh in $vmhs) { $myObj = "" | Select Name, UUID, RPname $myObj.Name = $vmh.name $myObj.UUID = Get-VM $vmh.name | %{(Get-View $_.Id).config.uuid} $myObj.RPname = $rp.name $myCol += $myObj } $myCol }
If you want to get from specific resourcepool , make changes as
Add $rpname = Read-Host "Please specify your Resourcepool" in place of "$rps = Get-ResourcePool"
Remove loop “ForEach ($rp in $rps)”
Replace $rp.name by $rpname in "$VMHs = Get-VM -Location (Get-ResourcePool -Name $rp.name)"
Remove “RPname” from “Select Name, UUID, RPname”
Remove “$myObj.RPname = $rp.name”
Hope this helps