Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 293210

Re: one-liner get running OS & configured OS & Cluster name

$
0
0

Sure, same method, follow the ResourcePool parent path.

Note that I excluded the hidden folders 'host', 'Resources' and 'Datacenters' from the path.

 

Get-View -ViewType "VirtualMachine" -Property "Name","Config.GuestFullName","Guest.GuestFullName","Runtime.Host","ResourcePool" | 
Where-Object {($_.Config.GuestFullName -ne $_.Guest.GuestFullName) -and ($_.Guest.GuestFullName -ne $null) -and ($_.Guest.PowerState -ne "PoweredOn")} | 
Select-Object -Property Name, 
@{N="Configured OS";E={$_.Config.GuestFullName}}, 
@{N="Running OS";E={$_.Guest.GuestFullName}}, 
@{N="Cluster Name";E={
    $parent = Get-View $_.Runtime.Host -Property Parent,Name
    while($parent -isnot [VMware.Vim.ClusterComputeResource]){
        $parent = Get-View $parent.Parent -Property Parent,Name
    }
    $Parent.Name
    }},
@{N="Resourcepool";E={
    $parent = Get-View $_.ResourcePool -Property Parent,Name
        $path = $parent.Name
        while($parent.Parent){
            $parent = Get-View $parent.Parent -Property Parent,Name
            if("Datacenters","host","Resources" -notcontains $parent.Name){
               $path = $Parent.Name + "/" + $path
            }         }        
$path
    }}

 

I left out Format-Table -AutoSize, I'm not sure it will fit on 1 line


Viewing all articles
Browse latest Browse all 293210

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>