One-Liner Powershell to get VMs Name, Network and Datastore

Get-Esx vCenterServer01

$vms = get-vm

Foreach ($vm in $vms) {get-vm $vm | select Name,@{N="Network";E={$_ | `
Get-NetworkAdapter | %{$_.NetworkName}}},`
@{N="Datastore";E={$_ |Get-Datastore | %{$_.Name}}}}


Name            Network             Datastore
----            -------             ---------
Server001       100_MGT             MGMT_SAS_1

The script at the top produces this type of output.  You need to define the $vms variable with a command before it like
$vms = get-vm

or  

$vms = "Server01","Server02","Server03"

C

Comments