PowerCLI: Two “vHardware” One-Liners


image

The first one-liner will return all the Virtual Machines which are not upgraded to vSphere yet.

Get-View -ViewType VirtualMachine | Where-Object `
{-not $_.config.template -and $_.Config.Version -eq "vmx-04" } | Select Name

The second one-liner will return all the Virtual Machines which are not upgraded to vSphere and where the VMware Tools are not upgraded.

Get-View -ViewType VirtualMachine | Where-Object `
{-not $_.config.template -and $_.Config.Version -eq "vmx-04"`
-and $_.Guest.ToolsVersion -lt "8193"} | Select Name

 

Update: If you want to count the Virtual Machines then you can run this one-liner:

(Get-View -ViewType VirtualMachine | Where-Object `
{-not $_.config.template -and $_.Config.Version -eq "vmx-04"`
-and $_.Guest.ToolsVersion -lt "8193"} | Select Name).Count

 

These two one-liners are part of a much bigger script. So keep an eye on http://ict-freak.nl šŸ˜‰

Advertisements

2 thoughts on “PowerCLI: Two “vHardware” One-Liners

  1. Glenn Sizemore

    Very nice, but I’ll take your one-liner and raise you a cmdlet šŸ˜€

    Get-View -ViewType VirtualMachine `
    -filter @{“Config.Template”=”false”;”Config.Version”=”vmx-04″} `
    -property Config, Name

    One-liners are fun, but performance can take a big hit if you lean too heavily on where. Side note you can also count by piping your output into measure-object. I prefer this method b/c it doesn’t require the () .

    Get-View -ViewType VirtualMachine | Measure

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s