VMware Cloud Community
AGFlora
Enthusiast
Enthusiast
Jump to solution

Having trouble populating Owner CustomAttribute

Get-VM | Select @{N="VM";E={$_.name}},@{N="Tools Version";E={$_.version}},

@{N="Owner";E={(Get-VM $_.name | Get-Annotation -CustomAttribute "Owner")}} |

Export-Csv tools.csv  -NoTypeInformation

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Perhaps try like this

Get-VM | Select @{N="VM";E={$_.name}},@{N="Tools Version";E={$_.version}},

@{N="Owner";E={(Get-VM $_.name | Get-Annotation -CustomAttribute (Get-CustomAttribute -Name "Owner"))}} |

Export-Csv tools.csv  -NoTypeInformation


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

View solution in original post

Reply
0 Kudos
6 Replies
LucD
Leadership
Leadership
Jump to solution

Perhaps try like this

Get-VM | Select @{N="VM";E={$_.name}},@{N="Tools Version";E={$_.version}},

@{N="Owner";E={(Get-VM $_.name | Get-Annotation -CustomAttribute (Get-CustomAttribute -Name "Owner"))}} |

Export-Csv tools.csv  -NoTypeInformation


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

Reply
0 Kudos
mattboren
Expert
Expert
Jump to solution

Hello, -

You were close.  Just needed to adjust the calculated property for "Owner" a bit, like:

    Get-VM | Select @{N="VM";E={$_.name}},@{N="ToolsVersion";E={$_.ExtensionData.Config.Tools.ToolsVersion}},
        @{N
="Owner";E={(Get-Annotation -Entity $_ -CustomAttribute "Owner").Value}} |
       
Export-Csv c:\temp\tools.csv -NoTypeInformation -UseCulture

Also, the value that you were using for "Tools Version" was actually the VM's virtual hardware version.  I adjusted that calculated property to get the VMware Tools version for the given VM.

That do it for you?

Edit:  doh, Luc is quicker than me on the response...

LucD
Leadership
Leadership
Jump to solution

But yours looks nicer Heart


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

Reply
0 Kudos
mattboren
Expert
Expert
Jump to solution

lol

Reply
0 Kudos
AGFlora
Enthusiast
Enthusiast
Jump to solution

This works...thanks

Reply
0 Kudos
AGFlora
Enthusiast
Enthusiast
Jump to solution

Thanks Matt

Reply
0 Kudos