Here is my another scripts which fetch information about all the VM from vcenter. Information includes internal partitions capacity and remaining, installed OS version v/s configured OS version on settings, vmtools info, vcenter server, rdm info, Nic types, snapshots, etc all this information from one script.
You can save this script to ps1 file and can be export to csv by using export-csv command.
lets assume you copied the code in text file and saved it in "c:\temp" folder with name "vm-inventory.ps1"
PS C:\temp>.\vm-inventory.ps1 | export-csv c:\temp\vmlist.csv -notypeinformation
Note: This script has been tested on Powercli 5.5 and Powershell v3
In second line of this script replace #vcenterserver with your vcenter ip or hostname
Add-PSSnapin vmware.vimautomation.coreConnect-Viserver #vcenterserver##################################### ## http://kunaludapi.blogspot.com ## Version: 1 ## Tested this script on ## 1) Powershell v3 ## 2) Powercli v5.5 ## 3) Vsphere 5.x ####################################function Get-VMinventory { function Get-RDMDisk { [CmdletBinding()] param ( [Parameter(Mandatory=$True)] [string[]]$VMName ) $RDMInfo = Get-VM -Name $VMName | Get-HardDisk -DiskType RawPhysical, RawVirtual $Result = foreach ($RDM in $RDMInfo) { "{0}/{1}/{2}/{3}"-f ($RDM.Name), ($RDM.DiskType),($RDM.Filename), ($RDM.ScsiCanonicalName) } $Result -join (", ") } function Get-vNicInfo { [CmdletBinding()] param ( [Parameter(Mandatory=$True)] [string[]]$VMName ) $vNicInfo = Get-VM -Name $VMName | Get-NetworkAdapter $Result = foreach ($vNic in $VnicInfo) { "{0}={1}"-f ($vnic.Name.split("")[2]), ($vNic.Type) } $Result -join (", ") } function Get-InternalHDD { [CmdletBinding()] param ( [Parameter(Mandatory=$True)] [string[]]$VMName ) $VMInfo = Get-VMGuest -VM $VMName # (get-vm $VMName).extensiondata $InternalHDD = $VMInfo.ExtensionData.disk $result = foreach ($vdisk in $InternalHDD) { "{0}={1}GB/{2}GB"-f ($vdisk.DiskPath), ($vdisk.FreeSpace /1GB -as [int]),($vdisk.Capacity /1GB -as [int]) } $result -join (", ") } foreach ($vm in (get-vm)) { $props = @{'VMName'=$vm.Name; 'IP Address'= $vm.Guest.IPAddress[0]; #$VM.ExtensionData.Summary.Guest.IpAddress 'PowerState'= $vm.PowerState; 'Domain Name'= ($vm.ExtensionData.Guest.Hostname -split '\.')[1,2] -join '.'; 'vCPU'= $vm.NumCpu; 'RAM(GB)'= $vm.MemoryGB; 'Total-HDD(GB)'= $vm.ProvisionedSpaceGB -as [int]; 'HDDs(GB)'= ($vm | get-harddisk | select-object -ExpandProperty CapacityGB) -join " + " 'Datastore'= (Get-Datastore -vm $vm) -split ", " -join ", "; 'Partition/Size' = Get-InternalHDD -VMName $vm.Name 'Real-OS'= $vm.guest.OSFullName; 'Setting-OS' = $VM.ExtensionData.summary.config.guestfullname; 'EsxiHost'= $vm.VMHost; 'vCenter Server' = ($vm).ExtensionData.Client.ServiceUrl.Split('/')[2].trimend(":443") 'Hardware Version'= $vm.Version; 'Folder'= $vm.folder; 'MacAddress' = ($vm | Get-NetworkAdapter).MacAddress -join ", "; 'VMX' = $vm.ExtensionData.config.files.VMpathname; 'VMDK' = ($vm | Get-HardDisk).filename -join ", "; 'VMTools Status' = $vm.ExtensionData.Guest.ToolsStatus; 'VMTools Version' = $vm.ExtensionData.Guest.ToolsVersion; 'VMTools Version Status' = $vm.ExtensionData.Guest.ToolsVersionStatus; 'VMTools Running Status' = $vm.ExtensionData.Guest.ToolsRunningStatus; 'SnapShots' = ($vm | get-snapshot).count; 'DataCenter' = $vm | Get-Datacenter; 'vNic' = Get-VNICinfo -VMName $vm.name; 'PortGroup' = ($vm | Get-NetworkAdapter).NetworkName -join ", "; 'RDMs' = Get-RDMDisk -VMName $VM.name #'Department'= ($vm | Get-Annotation)[0].value; #'Environment'= ($vm | Get-Annotation)[1].value; #'Project'= ($vm | Get-Annotation)[2].value; #'Role'= ($vm | Get-Annotation)[3].value; } $obj = New-Object -TypeName PSObject -Property $Props Write-Output $obj | select-object -Property 'VMName', 'IP Address', 'Domain Name', 'Real-OS', 'vCPU', 'RAM(GB)', 'Total-HDD(GB)' ,'HDDs(GB)', 'Datastore', 'Partition/Size', 'Hardware Version', 'PowerState', 'Setting-OS', 'EsxiHost', 'vCenter Server', 'Folder', 'MacAddress', 'VMX', 'VMDK', 'VMTools Status', 'VMTools Version', 'VMTools Version Status', 'VMTools Running Status', 'SnapShots', 'DataCenter', 'vNic', 'PortGroup', 'RDMs' # 'Folder', 'Department', 'Environment' 'Environment' } } Get-VMinventory
Output:
You can let me know what else can I can add to fetch any other information regarding vm in this script. Keep on checking comment you might find some answers.
extra extended vm inventory using powershell Part 2

10 comments:
Nice article admin thanks for share your atricle keep share your knowledge i am waiting for your new post check hi vis jacket girls knee high socks kindly review and reply me
Access your accounting dashboard quickly with canopy accounting log in portal Securely manage documents, track deadlines, and collaborate with clients online, making financial management simple, organized, and convenient for professionals and individuals alike.
Stay on top of your accounting tasks using canopy accounting log in portal This secure portal lets you manage files, streamline workflows, and communicate with clients, ensuring smooth and efficient financial management for everyone.
With canopy accounting log in portal, you can easily access your projects, share documents, and track progress. It’s designed to make accounting and tax management stress-free and accessible for all users.
Simplify your accounting experience through canopy accounting log in portal Securely log in to manage files, collaborate with clients, and organize tasks, offering a user-friendly way to keep financial responsibilities under control.
Manage your accounting needs effortlessly with canopy accounting log in portal From accessing documents to tracking deadlines, this secure platform helps you stay organized and in control of your financial tasks anytime, anywhere.
Activate your new Discover card through www.discovercard.com login and start earning rewards.
Securely complete card activation at www.discovercard.com login for immediate account access.
Activate your Discover card securely through www.discovercard.com login and start earning rewards today.
Activate your Discover card quickly through www.discovercard.com login and access benefits today.
Secure card setup starts at www.discovercard.com login for fast account activation.
Access your Discover card benefits, rewards, and online tools. Use www.discovercard.com login to activate your card safely today.
Make the most of your new Discover card experience. Go to www.discovercard.com login and complete
Activate your Discover card securely with www.discovercard.com login and start managing benefits today.
Activate your new card quickly using www.discovercard.com login and start spending today.
Secure card activation begins at www.discovercard.com login for fast account access.
Get instant access to your Discover card features and services. Visit www.discovercard.com login to activate your card securely online.
Start enjoying cashback rewards and account benefits today. Head to www.discovercard.com login and activate your Discover card fast.
New Discover card in hand? Complete the setup process through www.discovercard.com login and begin using your card immediately.
Securely activate your Discover credit card from anywhere. Simply access www.discovercard.com login and follow the easy instructions.
Avoid delays and start using your Discover card right away. Visit www.discovercard.com login to complete activation in minutes.
Unlock Discover rewards by visiting www.discovercard.com login and activating your card for faster transactions and secure billing.
Getting your Discover Card ready to use only takes a few moments. Visit www.discovercard.com login to verify your card details and finish activation securely.
Activate your Discover card quickly and securely online with simple steps. Visit www.discovercard.com login to start using your card today.
Ready to unlock your card benefits and rewards? Go to www.discovercard.com login and complete activation in just a few minutes.
Manage your new Discover card with ease and confidence. Use www.discovercard.com login to activate your account and begin spending.
Manage Discover benefits with ease by activating your card at www.discovercard.com login, ensuring secure and reliable access to financial tools.
Unlock Discover financing tools by visiting www.discovercard.com login and activating your card for seamless payments and cashback rewards.
Activate your Discover card online at www.discovercard.com login to enjoy faster access to payments, rewards, and personalized services.
Hassle-free activation is available at www.discovercard.com login, giving you instant access to financial resources and secure account management.
Secure your Discover account by completing activation at www.discovercard.com login, ensuring safe access to benefits and payments.
Unlock Discover rewards by visiting www.discovercard.com login and activating your card to gain access to exclusive cashback offers and benefits.
Manage billing and payments easily through www.discovercard.com login, where activation is quick, secure, and designed for convenience.
Get Discover perks instantly by visiting www.discovercard.com login and activating your account for rewards, discounts, and secure transactions.
Complete your Discover card setup at www.discovercard.com login and enjoy seamless account management with personalized financial services.
Activate your Discover account at www.discovercard.com login for secure access to payments, rewards, and exclusive member benefits.
Stay in control of your finances—activate your card at www.discovercard.com login and manage payments, rewards, and billing with ease.
Discover cardholders can activate their accounts quickly at www.discovercard.com login and begin enjoying personalized services and secure online tools.
Secure your financial journey by completing activation at www.discovercard.com login, ensuring safe access to payments, rewards, and account details.
Use the information provided with your new card to complete activation. www.discovercard.com login offers a simple online process that helps you start using your card quickly.
Activate your Discover card at www.discovercard.com login to enjoy faster transactions, secure billing, and personalized financial management tools.
Post a Comment