14 Dec 2016

Quick VM Report with PowerCLI

PowerCLI Script OverView

I primarily use this PowerCLI script after performing VM migrations. The script output focuses on what changed during the migration. Specifically moving to hosts running a newer version of ESXi.

The script is simple to modify and adapt to fit your specific needs.

Using the Script

To make use of the script, all that you need to do is set the $ClusterName and $Path values at the beginning. However, think of this not as a ‘run as it is’ script. Consider, this to be a framework.

 
$ClusterName = “ENTER CLUSTER NAME”
$Path = “Enter CSV Output path”


get-cluster $ClusterName | Get-VM |
Select Name,
@{N="Host"; E={$_.vmhost}},
@{N="Datastore";E={[string]::Join(',',(Get-Datastore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},
@{N="Folder";E={$_.Folder.Name}},
@{N="Hardware";E={$_.version}},
@{N="ToolsStatus";E={$_.ExtensionData.Guest.ToolsStatus}},
@{N="ToolsVersion";E={$_.ExtensionData.Guest.ToolsVersion}} |
Export-Csv $Path
Thank You For Reading