Sometimes it’s a painful job to extract all the information from vCenter server. From GUI you could export information, but not all the information will be available. I was requested to extrach following information.
- VM Name
- Host Name
- VM IP Address
- Installed Guest OS
- Power State of VM
- Allotted number of CPU
- Allotted total memory
- Connected Data store
- Host Server
- Host Cluster
There is no way we could extract all the above information from vCenter GUI, so I have created a PowerShell script using PowerCLI which will extract all the required information in following order.

Use this following PowerShell script to export all the information in one go.
$ExportPath = "Output CSV file FullPath"
$VmInfo = Get-VM
$VMS = ($VmInfo).Name
$VCenter = @()
foreach ($VM in $VMS)
{
$HostServer = (($VmInfo | ? {$_.Name -eq $VM}).Host).Name
$VMSysInfo = Get-VMGuest -VM $VM
$MyObject = New-Object PSObject -Property @{
VMName = $VM
VMHostName = $VMSysInfo.HostName
VMIP = $VMSysInfo.IPAddress
VMInstalledOS = $VMSysInfo.OSFullName
PowerState = ($VmInfo | ? {$_.Name -eq $VM}).PowerState
NumberOfCPU = ($VmInfo | ? {$_.Name -eq $VM}).NumCpu
MemoryGB = (($VmInfo | ? {$_.Name -eq $VM}).MemoryMB/1024)
VMDataS = (Get-Datastore -VM $VM).Name
HostServer = (($VmInfo | ? {$_.Name -eq $VM}).Host).Name
HostCluster = (Get-Cluster -VMHost $HostServer).Name
}
$VCenter += $MyObject
}
$VCenter |
Select VMName,
VMHostName,
@{N='VMIPAddress';E={$_.VMIP -join '; '}},
VMInstalledOS,
PowerState,
NumberOfCPU,
MemoryGB,
@{N='VMDataStore';E={$_.VMDataS -join '; '}},
HostServer,
HostCluster |
Export-Csv $ExportPath -NoTypeInformation
Update : Fixed VM Installed OS.
Ditching PsExec – Running Interactive SYSTEM Shells Natively in PowerShell
If you’ve spent any time in Windows System Administration over the last…
From The Blinking Cursor to The Thinking Machine: A Memoir of Automation
There is a specific kind of silence that only exists in a…
S3 Bucket Audit Report using AWS PowerShell Script – Secure your S3 Buckets
If you are working on AWS environment and if you follow…
Task Scheduler Error “A specified logon session does not exist” – Fix via Command Line and PowerShell for Scripting
This is very know issue, if you search internet, you will get…