VMware Cloud Community
CliveRichardson
Contributor
Contributor

Newbie needs some help doing basic PowerCLI reporting of hosts and VMs

I'm not a VMware specialist but I manage a large SQL Server estate that is hosted on VMs.  I'm familiar with Powershell.   As part of my reporting, I want to generate information such as Cluster, Host, VMs, LUN connection, etc.   I can't connect or do anything so far so this is literally step 1.   Could someone help me get off the ground with this?  For starters, a simple list of Hosts and VMs would be great.

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

First you will need to connect to the vCenter with the Connect-VIServer cmdlet.

Then the Get-VMHost and/or Get-VM cmdlets will retrieve the info for you.

Something like this

Get-VM |

Select Name,@{N='VMHost';E={$_.VMHost.Name}}

You can also go for a ForEach loop over all ESXi nodes.

Something like this

foreach($esx in Get-VMHost){

    Get-VM -Location $esx |

    Select Name,@{N='VMHost';E={$esx.Name}}

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
nemoi
Contributor
Contributor

A little more info about Connect-VIServer

Roman Gelman @ps1code
Reply
0 Kudos
CliveRichardson
Contributor
Contributor

Thank you.  I will try it out once I get the names of the VI Centers, etc.

Reply
0 Kudos