VMware Cloud Community
pamiller21
Enthusiast
Enthusiast
Jump to solution

VMTools Out-of-Date Report

Hey all,

I have a script to report out of date vmware tools and it works but it also shows vms that the tools are not running because the vm is not running either.  Here is my script:

add-pssnapin VMware.VimAutomation.Core

Connect-VIServer 127.0.0.1 -Protocol https -User <USERNAME> -Password <PASSWORD>

Get-VM | Get-View | Select-Object @{N=”VM Name”;E={$_.Name}},@{Name=”VMware Tools”;E={$_.Guest.ToolsStatus}} | Export-CSV ""

Get-View -ViewType VirtualMachine -Property Name,Guest.ToolsStatus -Filter @{

  "Config.Template"="False";"Guest.ToolsStatus"="^(?!toolsOk$).*$" } | `

Select-Object Name,@{Name="ToolsStatus";E={$_.Guest.ToolsStatus}} | `

Export-CSV -Path "<DIR>" -NoTypeInformation -UseCulture

Any help would be very appreciated,

Andy

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this, it adds a check for the powerstate in the filter

Add-PSSnapin VMware.VimAutomation.Core
Connect-VIServer 127.0.0.1 -Protocol https -User MyAccount -Password MyPassword
Get-View -ViewType VirtualMachine -Property Name,Guest.ToolsStatus,Config.Template,Runtime.PowerState -Filter @{
 
"Config.Template"="False";"Runtime.PowerState"="poweredOn";"Guest.ToolsStatus"="^(?!toolsOk$).*$" } |
Select-Object Name,@{Name="ToolsStatus";E={$_.Guest.ToolsStatus}} |
Export-CSV -Path C:\report.csv -NoTypeInformation -UseCulture


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

View solution in original post

1 Reply
LucD
Leadership
Leadership
Jump to solution

Try like this, it adds a check for the powerstate in the filter

Add-PSSnapin VMware.VimAutomation.Core
Connect-VIServer 127.0.0.1 -Protocol https -User MyAccount -Password MyPassword
Get-View -ViewType VirtualMachine -Property Name,Guest.ToolsStatus,Config.Template,Runtime.PowerState -Filter @{
 
"Config.Template"="False";"Runtime.PowerState"="poweredOn";"Guest.ToolsStatus"="^(?!toolsOk$).*$" } |
Select-Object Name,@{Name="ToolsStatus";E={$_.Guest.ToolsStatus}} |
Export-CSV -Path C:\report.csv -NoTypeInformation -UseCulture


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