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

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
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteManaging taxes online is easier than ever with cash app tax login Securely access your account, review filings, and stay organized with a simple, user-friendly platform designed to make tax season stress-free for everyone.
ReplyDeleteLooking for a quick way to handle taxes? The cash app tax login feature lets you safely sign in, track returns, and manage documents with ease. It’s a reliable tool for simplifying tax preparation for all users.
ReplyDeleteStay on top of your taxes effortlessly using cash app tax login With secure access and easy navigation, you can manage filings, check updates, and keep everything organized in one place—perfect for anyone wanting stress-free tax management.
ReplyDeleteAccess your tax dashboard easily with cash app tax login Securely manage returns, check past filings, and update account details, making tax preparation simple and convenient for everyone.
ReplyDeleteAccess your tax dashboard easily with cash app tax login Securely manage returns, check past filings, and update account details, making tax preparation simple and convenient for everyone.
Accessing your Shop Your Way account is simple with Citi syw account online payment Quickly make payments, check balances, and manage transactions online, giving you peace of mind and convenience.
ReplyDeleteManage your credit card effortlessly through Citi syw account online payment From viewing statements to making payments, this secure portal helps you stay organized and in control of your finances.
The Citi syw account online payment portal makes financial management easy. Log in to pay bills, monitor activity, and update account details securely, offering convenience for everyone.
Stay connected to your finances with Citi syw account online payment This user-friendly platform allows you to manage payments, track spending, and access account details anytime, anywhere.
Using Citi syw account online payment , you can securely log in to manage your account, pay bills, and review statements. It’s a simple way to keep your credit card organized and under control.
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.
ReplyDeleteStay 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 Amazon services easily with www.amazon.com mytv login Enter your code, link devices, and enjoy seamless access to Prime Video, apps, and more—all in just a few simple steps.
ReplyDeleteWith www.amazon.com mytv login, connecting your device is quick and secure. Enter the code provided, sign in, and instantly unlock access to Amazon Prime Video, apps, and personalized entertainment.
Simplify streaming setup using www.amazon.com mytv login This easy process lets you link devices, access Prime Video, and enjoy your favorite shows without hassle, making entertainment convenient for everyone.
Enjoy effortless device setup with www.amazon.com mytv login Enter your activation code, connect to your Amazon account, and start streaming movies, shows, and apps instantly from the comfort of your home.
The www.amazon.com mytv login feature makes linking devices simple. Securely enter your code, connect to your account, and enjoy unlimited access to Prime Video and Amazon apps in minutes.