Skip to content

Instantly share code, notes, and snippets.

@PatrickTerlisten
Last active December 5, 2015 08:24
Show Gist options
  • Save PatrickTerlisten/43870095d6c5b2f133da to your computer and use it in GitHub Desktop.
Save PatrickTerlisten/43870095d6c5b2f133da to your computer and use it in GitHub Desktop.
This script outputs a list of all VMs without VMware Tools or with VMware Tools that needs to be updated.
#requires -Version 1
#requires -PSSnapin VMware.VimAutomation.Core
function Get-OutdatedVMTools {
<#
.SYNOPSIS
No parameters needed. Just execute the script.
.DESCRIPTION
This script outputs a list of all VMs without VMware Tools or with VMware Tools that needs to be updated.
.EXAMPLE
Get-OutdatedVMTools
Get a list of all VMs with outdated VMware Tools.
.NOTES
Author: Patrick Terlisten, [email protected], Twitter @PTerlisten
This script is provided "AS IS" with no warranty expressed or implied. Run at your own risk.
This work is licensed under a Creative Commons Attribution NonCommercial ShareAlike 4.0
International License (https://creativecommons.org/licenses/by-nc-sa/4.0/).
.LINK
http://www.vcloudnine.de
#>
# Create empty hash table
$OutputTable = @()
# Get a list of all VMs
$AllVMs = Get-VM
try
{
# Loop to process each VM and fill the $OutputTable hash table
ForEach ($VM in ($AllVMs | Get-View)) {
$Output = ''| Select-Object -Property VM
If (($VM.Guest.get_ToolsVersionStatus() -eq 'guestToolsNeedUpgrade') -or `
($VM.Guest.get_ToolsVersionStatus() -eq 'guestToolsNotInstalled')) {
$Output.VM = $VM.Name
$OutputTable += $Output
}
}
}
catch
{
"Error was $_"
$line = $_.InvocationInfo.ScriptLineNumber
"Error was in Line $line"
}
finally
{
# Output the filled hash table
If ($OutputTable.Length -eq 0) {Write-Host -Object 'No VMs with outdated Tools found!'}
else {$OutputTable}'I can do cleanup things here'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment