VMware Cloud Community
PELEGIT
Contributor
Contributor
Jump to solution

Powercli

Hi Guys,

I have prepare the following smalls scripts:

   $vcvm = (get-vm -location "xxxCluster").Name

   $tag =  Get-TagAssignment -Entity $vcvm |  Where {$_.tag -notlike "*Information*" }  

   $VMowner=  (Get-vm -name $vcvm).CustomFields | where {$_.key -like "VM Owner" }

I would like to get a simple table that shows VM Name, tag of VM and VM Owner vaule of VM as well,

Can you assist?, should I use on Array here?

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I would use calculated properties on a Select-Object.

Something like this

Get-VM -Location $cluster |

Select Name,

    @{N='Tag';E={(Get-TagAssignment -Entity $_ | where{$_.Tag.Name -notlike "*Information*"}).Tag.Name -join '|'}},

    @{N='Owner';E={($_.CustomFields | where {$_.key -like "VM Owner" }).Value}}


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

View solution in original post

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

I would use calculated properties on a Select-Object.

Something like this

Get-VM -Location $cluster |

Select Name,

    @{N='Tag';E={(Get-TagAssignment -Entity $_ | where{$_.Tag.Name -notlike "*Information*"}).Tag.Name -join '|'}},

    @{N='Owner';E={($_.CustomFields | where {$_.key -like "VM Owner" }).Value}}


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

Reply
0 Kudos