VMware Cloud Community
vmCalgary
Enthusiast
Enthusiast
Jump to solution

Get-VM Name, powerstate VM tag=Exclude

I have a list of vms in a txt file.

$VM = Get-Content filename.txt

For each VM I want to the following:

Name

Powerstate

Tags

The Tag I want to verify is category = Exclude.

I am not sure how to get that in one simple script.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Something like this?

Get-VM -Name (Get-Content filename.txt) |

Select Name,PowerState,

    @{N='Exclude';E={(Get-TagAssignment -Entity $_ -Category 'Exclude').Tag}}


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

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

Something like this?

Get-VM -Name (Get-Content filename.txt) |

Select Name,PowerState,

    @{N='Exclude';E={(Get-TagAssignment -Entity $_ -Category 'Exclude').Tag}}


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

vmCalgary
Enthusiast
Enthusiast
Jump to solution

Thank you, Luc. I was overthinking it. Keep it simple Smiley Happy

0 Kudos