VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Unable to get tags info

Hi,

I am unable to get tags info from the below command, Tags information is not clear. please help

Get-VM |

Select-object Name,  @{N = 'vCenter'; E = {([system.uri]$_.ExtensionData.Client.ServiceUrl).Host}},

   @{N='TagCategories';E={

    $script:assigned = Get-TagAssignment -Entity $_

    $script:assigned.Tag.Category.Name -join '|' }},

   @{N='Tags'; E = {$script:assigned.Name -join '|'}} | ft -auto

Output

Name                vCenter TagCategories            Tags
----                ------- -------------            ----
HADOOP02          demovcenter Department|Owner|Application com.vmware.cis.tagging.TagAssociationModel|com.vmware.cis.tagging.TagAssociationModel|com.vmware.cis.tagging.TagAssociationModel
HADOOP01          demovcenter Department|Application   com.vmware.cis.tagging.TagAssociationModel|com.vmware.cis.tagging.TagAssociationModel
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

That property is Tag.Name

Get-VM |

Select-Object Name,  @{N = 'vCenter'; E = {([system.uri]$_.ExtensionData.Client.ServiceUrl).Host}},

   @{N='TagCategories';E={

    $script:assigned = Get-TagAssignment -Entity $_

    $script:assigned.Tag.Category.Name -join '|' }},

   @{N='Tags'; E = {$script:assigned.Tag.Name -join '|'}} | ft -auto


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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

That property is Tag.Name

Get-VM |

Select-Object Name,  @{N = 'vCenter'; E = {([system.uri]$_.ExtensionData.Client.ServiceUrl).Host}},

   @{N='TagCategories';E={

    $script:assigned = Get-TagAssignment -Entity $_

    $script:assigned.Tag.Category.Name -join '|' }},

   @{N='Tags'; E = {$script:assigned.Tag.Name -join '|'}} | ft -auto


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Thank you very much LucD. That worked perfectly Smiley Happy

0 Kudos