VMware Cloud Community
mthiha207au
Enthusiast
Enthusiast
Jump to solution

host profile and associated hosts via powercli

Hi All,

How can I query the host profile and associated hosts with it? The closest thing I get is this.

(Get-VMhostProfile hostprofilename).extensiondata.entity

Type                         Value

-----                         ------

HostSystem          host-3026

HostSystem          host-3028

But, I am not getting the hostname and get only host value.

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VMHostProfile |

Select Name,

    @{N='VMHost';E={(Get-View -Id $_.ExtensionData.Entity).Name -join '|'}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VMHostProfile |

Select Name,

    @{N='VMHost';E={(Get-View -Id $_.ExtensionData.Entity).Name -join '|'}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
mthiha207au
Enthusiast
Enthusiast
Jump to solution

Thank you Master.LucD

Get-View . This is it.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yup, the moment you see a MoRef, you can get the object it is pointing to with the Get-View cmdlet.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
DavidGriswoldeB
Enthusiast
Enthusiast
Jump to solution

Sorry about necroing a 3 year old thread, but is there a reference back to Auto Deploy rules? We do not apply Host Profiles directly to clusters or ESXi hosts, so there is not a MoRef to those objects. 

I know I can just run Get-DeployRuleSet to see which Host Profiles are referenced to which rules, but looking for a one-liner that will do both for me, if possible.

Reply
0 Kudos