Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 168455

Re: Tags Issues

$
0
0

Example with 3 test VMs created. The third doesn't have any TAG associated to it.

 

Get-VM | where {$_.Name -match "TAG*"}| ForEach-Object {

$VM = $_

$Tag = $_ | get-tagassignment

If($Tag){

          $Tag.tag| foreach-object{

 

                $Output = New-Object -Type PSObject -Prop ([ordered]@{

                'VM' = $VM

                'Host' = $VM.VMhost

                'Notes' = $VM.Notes

                'TagCategory' = $_.Category

                'TagName' = $_.Name

                })    

                Return $Output

            }

}Else{

          $Tag.tag| foreach-object{

 

                $Output = New-Object -Type PSObject -Prop ([ordered]@{

                'VM' = $VM

                'Host' = $VM.VMhost

                'Notes' = $VM.Notes

                'TagCategory' = "NO TAG FOR THIS VM"

                'TagName' = "NO TAG FOR THIS VM"

                })    

                Return $Output

            }

}

} | ogv

 

And the output looks like:


Viewing all articles
Browse latest Browse all 168455

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>