Mar 082017
 

Here is a quick one-liner that will list your VM names and their Environment Tag.
- The assumption here is you use vCenter Tags, you created a tag category for Environment, created some tag types (like Production, Dev, etc) under that category, and assigned those Tags to your VMs.

$Thecategory = “Environment”
$thecluster = “TheCoolKidsCluster”
get-cluster $thecluster | Get-VM | Select Name,@{N=”Tag”;E={((Get-TagAssignment -category $Thecategory -Entity $_ | select -ExpandProperty Tag).Name -join “,”)}}

#The output can be sent to csv with  “|export-csv c:\temp\export.csv”
#The output looks like this:
VM1 Production
VM2 Development
VM3 Production…..
… etc

# Remember – you can change the get-cluster part to get-folder, get-datastore, get-datastorecluster, even a get-VDPortgroup!