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
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
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