Skip to content

Instantly share code, notes, and snippets.

@MarkDarwin
Last active July 5, 2017 13:31
Show Gist options
  • Save MarkDarwin/6b7447215d766303c23dd29f94bb73d0 to your computer and use it in GitHub Desktop.
Save MarkDarwin/6b7447215d766303c23dd29f94bb73d0 to your computer and use it in GitHub Desktop.
#Get a list of all VM's with version numbers to see if any need upgrading
#Move to PowerCli scripts folder and initialise
$PowerCliPath = "${env:ProgramFiles(x86)}\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"
$VIServer = "blah","blah2"
if (Test-Path -Path $PowerCliPath){
Write-Verbose -Message $PowerCliPath
$Installed = $true
}
If ($Installed -eq $true){
. $PowerCliPath $true
Connect-VIServer -Server $VIServer -Credential (Get-Credential)
}
#Make new properties to store version information in
New-VIProperty -Name ToolsVersion -ObjectType VirtualMachine -ValueFromExtensionProperty 'Config.tools.ToolsVersion' -Force
New-VIProperty -Name ToolsVersionStatus -ObjectType VirtualMachine -ValueFromExtensionProperty 'Guest.ToolsVersionStatus' -Force
#Get the list
Get-VM | Select Name, Version, ToolsVersion, ToolsVersionStatus | Sort-Object Version | Format-Table -AutoSize
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment