VMware Cloud Community
vmware-oebb
Contributor
Contributor
Jump to solution

Get-TagAssignment | select -ExpandProperty Tag

Hi,

How can I get the Tags of VMhost?

This Script works.

Get-Cluster -Name MS-ONLY | Get-VM  | Select Name,

@{N="Tags VM";E={((Get-TagAssignment -Entity $_ | select -ExpandProperty Tag).Name -join ",")}},

@{N="Datastore";E={Get-Datastore -VM $_}},

@{N="Cluster";E={Get-Cluster -VM $_}},

@{N="ESX Host";E={Get-VMHost -VM $_}},

@{N="Tags Host";E={Get-VMhost -VM $_ | Get-TagAssignment | select -ExpandProperty Tag | Select Name}}

But the Output is:

Tags VM : STRETCHED-MS-ONLY,ARS,WIEN

Datastore : ARS_SVC_MS-ONLY_VOL_13

Cluster : MS-ONLY

ESX Host : as12128.org.oebb.at

Tags Host : {@{Name=ARS}, @{Name=STRETCHED-MS-ONLY}, @{Name=WIEN}}

The Output should be:

Tags VM : STRETCHED-MS-ONLY,ARS,WIEN

Datastore : ARS_SVC_MS-ONLY_VOL_13

Cluster : MS-ONLY

ESX Host : as12128.org.oebb.at

Tags Host : ARS,STRETCHED-MS-ONLY,WIEN

thank's

Andi

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try changing that line into

@{N="Tags Host";E={(Get-VMhost -VM $_ | Get-TagAssignment | select -ExpandProperty Tag).Name -join ','}} 


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

Try changing that line into

@{N="Tags Host";E={(Get-VMhost -VM $_ | Get-TagAssignment | select -ExpandProperty Tag).Name -join ','}} 


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

0 Kudos
vmware-oebb
Contributor
Contributor
Jump to solution

Hi Luc,

Thank you so much. Works perfect.

Andi

0 Kudos