I'm a newbie to PowerCLI so please bare with me. I am trying to export a list of VMs within a cluster to excel with the following information: Guest OS, DNS Name, Host, and datastore VM is on.
Simple request for the vets out there but I'm still trying to work it out. Let me know if I need to provide additional information. Thanks!
Try something like this
Get-Cluster -Name MyCluster | Get-VM | Select Name,@{N="OS";E={$_.Guest.OSFullName}}, @{N="DNS";E={[string]::Join(',',($_.Guest.ExtensionData.Net[0].DnsConfig.IpAddress))}}, @{N="Host";E={$_.Host.Name}}, @{N="Datastore";E={[string]::Join(',',(Get-View $_.DatastoreIdList | %{$_.Name}))}} | Export-Csv .\report.csv -NoTypeInformation -UseCulture
The script assumes your VM only has 1 NIC.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This was definitely a good option. I just wasn't sure how choose a datastore. It didn't look like a datastore column was available. Very helpful though. Thanks!
I'll have to play around with this and see if it helps. It'll take me a while since I'm a newbie. Thanks!