VMware Cloud Community
G0nz0UK
Enthusiast
Enthusiast

Get-VM list Tools version/state help

Hello,

Does anyone have a simple script to share that lists the VMs and their tools version/state, but also based on a tag?

We only look after a a group of VMs based on a tag called 'dev' for example.

Thanks

0 Kudos
3 Replies
mmcgill1
VMware Employee
VMware Employee

Hi @G0nz0UK ,

Take a look at @LucD 's post on Get VMs with Tag...

You can add the VMTools Version to that code very easily.

Get-VM | Get-TagAssignment |
    where{$_.Tag -like 'dev'} |
    Select @{N='VM';E={$_.Entity.Name}}, @{N='ToolsVersion';E={$vm.ExtensionData.Config.Tools.ToolsVersion}}
 
You can pipe that output to a csv like LucD does in his example, or just echo it to the command line doing the above
0 Kudos
mmcgill1
VMware Employee
VMware Employee

@G0nz0UK , I'm going to correct one mistake I had and switch the code slightly.  Try this:

$tag = "dev"
Get-VM | Get-TagAssignment -Tag $tag | Select @{N='VM';E={$_.Entity.Name}}, @{N='ToolsVersion';E={$_.Entity.ExtensionData.Config.Tools.ToolsVersion}}
 
This will return the VM Name and the Tools Version.  
0 Kudos
LucD
Leadership
Leadership

Instead of using the costly (in execution time) Get-TagAssignment, you can use the Tag parameter on the Get-VM cmdlet.

 

Get-VM -Tag (Get-Tag -Name 'dev' ) |
Select Name,
    @{N='VMware Tools State';E={$_.ExtensionData.Guest.ToolsStatus}},
    @{N='VMware Tools Version';E={$_.ExtensionData.Guest.ToolsVersion}} |
Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture

 


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

0 Kudos