This script connect to your VI Server, then retrieve all the virtual machine names and get the VMware tools status and version.
Script:
Connect-VIServer -Server VIServerName get-vm | % { get-view $_.ID } | select Name, @{ Name="hostName"; Expression={$_.guest.hostName}}, @{ Name="ToolsStatus"; Expression={$_.guest.toolsstatus}}, @{ Name="ToolsVersion"; Expression={$_.config.tools.toolsVersion}} | sort-object name
References
Connect-VIServer
Synopsis
Connects to a vSphere server.
Syntax
Connect-VIServer [-Server] <String[]> [-Port <Int32>] [-Protocol <String>] [-Credential <PSCredential>] [-User <String>] [-Password <String>] [-Session <String>] [-NotDefault] [<CommonParameters>]
Related Commands
Detailed Description
Connects to a vSphere server. The cmdlet starts a new session or re-establishes a previous session with a vSphere server using the specified parameters.
You can have more than one connections to the same server. To disconnect from a server, you need to close all active connections to this server.
vSphere PowerCLI supports working with multiple default servers. If you select this option, every time when you connect to a different server using Connect-VIServer, the new server connection is stored in an array variable together with the previously connected servers, unless the -NotDefault parameter is set. This variable is named $DefaultVIServers and its initial value is an empty array. When you run a cmdlet and the target servers cannot be determined from the specified parameters, the cmdlet runs against all servers stored in the array variable. To remove a server from the $DefaultVIServers variable, you can either use Disconnect-Server to close all active connections to the server, or modify the value of $DefaultVIServers manually.
If you choose to work with a single default server, when you run a cmdlet and the target servers cannot be determined from the specified parameters, the cmdlet runs against the last connected server. This server is stored in the $defaultVIServer variable, which is updated every time you establish a new connection. Working with a single default server is deprecated and will be removed in a future release.
To switch between single and multiple default servers working mode, use the Set-PowerCLIConfiguration cmdlet.
Parameters
Input Type
Return Type
VMware.VimAutomation.Types.VIServer
Get-VM
Synopsis
Retrieves the virtual machines on a vSphere server.
Syntax
Get-VM [-Datastore <Datastore[]>] [-Location <VIContainer[]>] [[-Name] <String[]>] [-Id <String[]>] [-NoRecursion] [-Server <VIServer[]>] [<CommonParameters>]
Related Commands
Remove-VM
New-VM
Set-VM
Move-VM
Start-VM
Stop-VM
Suspend-VM
Restart-VM
Detailed Description
Retrieves the virtual machines on a vSphere server. Returns a set of virtual machines that correspond to the filter criteria provided by the cmdlet parameters. For virtual machines with multiple NICs and multiple IP addresses, the IPAddress property of the VMGuest object contains all IP addresses of the virtual machine. The IP at position 0 is the primary IP address.
Parameters
Input Type
Return Type
VMware.VimAutomation.Types.VirtualMachine