VMware Cloud Community
mdterp
Enthusiast
Enthusiast

Scripting the documentation of about 100 ESX servers

I have Power GUI running and am generally happy with the Generate vReport option.  However I'd like a script that can automatically find all the ESX servers on my network - then generate the vReport.

Someday I'd like to figure out how to customize the output of the vReport from PowerGUI, but that is for a different time and a different forum.

Does anyone have any basic scripts that can go out and find ESX servers on my network, grab pertinent information (hostname, IP, ESX version, what VMs are running) then output to a csv or some other format.

Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

When you are connected to the vCenter, through the Connect-VIServer cmdlet, this

Get-VMHost

should return all the ESX servers that are managed by the vCenter.


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

Reply
0 Kudos
mdterp
Enthusiast
Enthusiast

Right now we do not have vCenter.  They are all simply just various ESX hosts on the network.  So there probably isn't a great and easy way to get them all.  I have been reading about a VMware API that someone made a scanner with that sounds promising.

Downloads

Reply
0 Kudos
ssbkang
Enthusiast
Enthusiast

Without a vCenter server, you will probably have to create an input file with the hostname, username and password.

I would recommend the following.

Input (esxi.csv):

Name,Username,Password

test1.test.com,username,password

test2.test.com,username,password

test3.test.com,username,password

Script (make sure the input file, esxi.csv is in same directory with the script):

$output = foreach ($esxi in Import-Csv esxi.csv)

{

     Connect-VIServer -User $esxi.Username -Password $esxi.Password -Server $esxi.Name

     Get-VMHost -Name $esxi.Name | Select-Object @{N="ESXi";E={$_.Name}},

                                                                           @{N="Management IP";E={$_.ExtensionData.Summary.ManagementServerIP}},

                                                                           @{N="Virtual Machine";E={[string]::Join(",", ($_ | Get-VM | %{$_.Name}))}}                             

}

Disconnect-VIServer * -Confirm:$false

$output | Export-Csv output.csv

Sample Output:


esxtst01.test.com     443   root                                                                                                                                                                                                                                                                                    

                                                                                                                                                                                                                                                                                                                             

ESXi            : esxtst01.test.com

Management IP   : 10.1.1.1                                                                                                                                                                                                                                                                                            

Virtual Machine : test1,test2,test3,test4                                                                                                                                                                                                                                                                                    

                                                                                                                                                                                                                                                                                                                             

esxtst02.test.com     443   root                                                                                                                                                                                                                                                                                    

                                                                                                                                                                                                                                                                                                                             

ESXi            : esxtst02.test.com

Management IP   : 10.1.1.2                                                                                                                                                                                                                                                                                              

Virtual Machine : test5,test6,test7,test8       

Hope this helps,

Steven.                                                                                                                                                                                                                                                                           

Reply
0 Kudos