VMware Cloud Community
oasisinin
Enthusiast
Enthusiast

powercli: listing only linux vms with VMtools need update

Hello all

Looking for a script that can list "only" the linux VMs which need VMtools to be updated

Idea is to automated email to linux admins whenever VMtools need to be updated

Thank You

Tags (3)
Reply
0 Kudos
11 Replies
LucD
Leadership
Leadership

Try something like this

Get-VM |

where{$_.Guest.GuestFamily -match 'linux' -and $_.Guest.ExtensionData.ToolsStatus -eq 'toolsOld'} |

Select Name


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

Reply
0 Kudos
oasisinin
Enthusiast
Enthusiast

"$_.Guest.GuestFamily -match 'linux'" its not returning anything

tried with Guest.GuestFullName as well; no avail.

Get-VM | where{$_.Guest.ExtensionData.ToolsStatus -eq 'toolsOld'} returns list of all VMs with outdated/old tools

Reply
0 Kudos
LucD
Leadership
Leadership

And what do your Linux VMs display for the GuestFamily and GuestFullname ?


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

Reply
0 Kudos
oasisinin
Enthusiast
Enthusiast

This is exactly what I am trying....

Get-Cluster "CLUSTER" | Get-VM | where{$_.Guest.GuestFamily -match 'linux'} or

Get-Cluster "CLUSTER" | Get-VM | where{$_.Guest.GuestFullName -match 'linux'}

result is Blank

Smiley Sad

Reply
0 Kudos
LucD
Leadership
Leadership

I ment, what do you see when you do this

Get-VM | Select Name,@{N='Family';E={$_.Guest.GuestFamily}},

  @{N='OS';E={$_.Guest.OSFullName}}


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

Reply
0 Kudos
oasisinin
Enthusiast
Enthusiast

It lists the VMs with Name, Family and OS

Name and OS are good but the Family column is blank

Reply
0 Kudos
LucD
Leadership
Leadership

Provided the OS name contains the work "linux" you could do something like this

Get-VM |

where{$_.Guest.OSFullName -match 'linux' -and $_.Guest.ExtensionData.ToolsStatus -eq 'toolsOld'} |

Select Name


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

Reply
0 Kudos
oasisinin
Enthusiast
Enthusiast

Thank You; I get a listing of linux VMs which need tools update

is it possible to get a column with "Tools Status" and "Guest OS" as well?

Reply
0 Kudos
LucD
Leadership
Leadership

Sure, something like this

Get-VM |

where{$_.Guest.OSFullName -match 'linux' -and $_.Guest.ExtensionData.ToolsStatus -eq 'toolsOld'} |

Select Name,@{N='OS';E={$_.Guest.OSFullName}},

  @{N='Tools Status';E={$_.Guest.ExtensionData.ToolsStatus}}


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

Reply
0 Kudos
oasisinin
Enthusiast
Enthusiast

Yay!!!

one last thing Smiley Wink

I only get Out of Date / toolsOld  under status, can i also get 'tools not installed' VMs as well?

Reply
0 Kudos
LucD
Leadership
Leadership

Sure, try like this

Get-VM |

where{$_.Guest.OSFullName -match 'linux' -and 'toolsOld','toolsNotInstalled' -contains $_.Guest.ExtensionData.ToolsStatus} |

Select Name,@{N='OS';E={$_.Guest.OSFullName}},

  @{N='Tools Status';E={$_.Guest.ExtensionData.ToolsStatus}}


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

Reply
0 Kudos