Hello Admins,
 
I hope all the VMware Admins need VM inventory who don’t have a tool which will give VM’s details. Here is the script which will give you more details about the VM. There are other tools or script which will give you VM details but it is in more details. I personally experienced that these information we usually needed if running condition or if something goes wrong or failure. You can get complete VM settings & configuration for future reference to a VM got deleted or lost, so if you have this VM inventory you can get the details or find the VM.
 
Try and follow the below instruction.

DO NOT FORGET to acknowledge by click on STARs  if you liked it. J

 

This script will connect to vSphere client and get the VMs from connected VC. It will gather all the VM information which needs for every Admin to have as a VM inventory to check quickly or refer in future if something goes wrong. Script may takes time to fetch the information as it is gathering deep information of the VM to so you can schedule the script to fetch the information.
VM inventory output will be store in CSV format so we can manage or play with data.
 
You will see VC selection menu when you run the script.
Condition : - If PowerCLI is installed on your machine, otherwise popup message with redirect you to PowerCLi Download tool page.

 

Script Started at - 05-Jan-2017 07:06:30 

 

===================================================

#                                      @mol patil #

#                                               

#                  VM Inventory Script              

#

#   Welcome : amolpatil

#                         

#   PowherShell Version : 4.0

#   PowherCLI Version   : 5.5.0.0

#   Execution Policy    : Unrestricted                                  

===================================================

 

Enter your choice to select VC.

===================================================

 

[1] Enter VC_Name manually(Enter).

 

[2] VC_Name entered in Script.

 

[3] Get VC_Name(s) from file.

 

[0] Exit.

===================================================

 

If PowerCLI not installed it will not run further.

Script Started at - 05-Jan-2017 20:35:19 

 

===================================================

#                                      @mol patil #

#                                               

#                  VM Inventory Script              

#

#   Welcome : amolpatil

#                         

#   PowherShell Version : 5.0.10586.0

#   PowherCLI Version   : PowerCli Not Installed

#   Execution Policy    : Restricted                                  

===================================================

 

Thank you, Good Bye !


Enter your choice menu:
You can set default VC name in script to use VC_name default.
Here you need to add.. Line number 344
#region      VC Selection Menu <1/5/2017>  #========================================================================= 
Function DefaultVC {$vCs = "VC1"} # ======================================================================== 
Function manualVC {$VCs = Read-Host "Enter Virtual Center Name (Single) : "} # ======================================================================== 
Function VCfromfile {$VCs= Get-Content ($SCRIPT_PARENT + "\VC_List.txt") -ErrorAction SilentlyContinue } #@======================================================================== 
Function Bye { Exit }
#@======================================================================== 
#Gather info from user input. 
   
On line number 157 => You can fetch the VM information from limited VMs to test. By removing # before “| select”
$VMs = Get-VM #| select -First 5   
 To  $VMs = Get-VM | select -First 5 

 

 

 

Output will store in Reports folder.
C:\_Script\VMware\_@VM_Inventory_New_04jan2017\Reports\VC1_VM_Inventory_Report(Complete)_04-01-2017.csv  

 

PowerShell
Edit|Remove
Write-Host "" 
@" 
=================================================== 
#                                       @mol patil # 
#                                                 
#                VM Inventory Script                    
# 
#   Welcome : $env:USERNAME 
#                           
#   PowherShell Version : $PSVersion 
#   PowherCLI Version   : $pcli 
#   Execution Policy    : $policy                                    
=================================================== 
"@  
#endregion 
  
  

Regards,

Amol Patil