Hi,
I need to get VM and the Tag(s) assigned to it, but couldn't get a correct result, could you please review this simple script, or give me another idea.
$getvm = get-vm
Get-vm | Get-TagAssignment | select -Property @{N="VM Name";E={$getvm}} , Tag
Thanks,
Try like this
Get-VM |
Select Name,@{N='Tags';E={(Get-TagAssignment -Entity $_).Tag -join '|'}}
Or if you only want to see VMs that have a Tag assigned
Get-TagAssignment |
Select @{N='VM';E={$_.Entity.Name}},Tag
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try like this
Get-VM |
Select Name,@{N='Tags';E={(Get-TagAssignment -Entity $_).Tag -join '|'}}
Or if you only want to see VMs that have a Tag assigned
Get-TagAssignment |
Select @{N='VM';E={$_.Entity.Name}},Tag
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks LuCD,
The second command needs a little modification in the suffix to be like this:
Get-VM | Get-TagAssignment | Select @{N='VM';E={$_.Entity.Name}},Tag
Good day,