Skip to content

Instantly share code, notes, and snippets.

@jbarber
Created April 27, 2011 10:56
Show Gist options
  • Save jbarber/944059 to your computer and use it in GitHub Desktop.
Save jbarber/944059 to your computer and use it in GitHub Desktop.
Enumerate VMware guests and the datastores each one uses
$vms = get-view -type virtualmachine
$hosts = $vms | %{
$obj = New-Object Object
$obj | Add-Member noteproperty name $_.name
$obj | Add-Member noteproperty datastores ($_.datastore | %{(get-view -Id $_).Name})
$obj
}
# Dump to CSV
$hosts | convertto-csv > hosts.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment