A quick script to gather information about your vCenter estate for CMDB.
#Connect vCenter Servers
Connect-Viserver uk3p-vc01.lab.local, ntcp-vc01.lab.local
Get-Cluster | Get-VM | where { ($_ | Get-VirtualPortGroup )} | Select Name, Powerstate, NumCPU, corespersocket, memoryGB, version, guestid, vmhost,
@{N="Datacenter";E={Get-DataCenter -VM $_}}, `
@{N="Cluster";E={Get-Cluster -VM $_}}, `
{ [PSCustomObject] @{ vCenter = $_.Uid.Substring($_.Uid.IndexOf('@')+1).Split(":")[0] } }, `
@{N="ESXi Host";E={Get-VMHost -VM $_}}, `
@{N="Datastore";E={Get-Datastore -VM $_}}, `
@{N="MacAddress";E={[string]::Join(',',($_.Guest.Nics | %{$_.MacAddress}))}}, `
@{N="VLanID";E={[string]::Join('#',(Get-VirtualPortGroup -VM $_ | %{$_.VLanID}))}}, `
@{N="PortGroup";E={Get-VirtualPortGroup -VM $_}}| `
Export-Csv -NoTypeInformation C:\Scripts\VM_CLuster_Host_Datastore_PortGroup_vLANiD.csv
#Stop Script
Stop-Transcript
## Save as CMDB_Report.ps1
#Connect vCenter Servers
Connect-Viserver uk3p-vc01.lab.local, ntcp-vc01.lab.local
Get-Cluster | Get-VM | where { ($_ | Get-VirtualPortGroup )} | Select Name, Powerstate, NumCPU, corespersocket, memoryGB, version, guestid, vmhost,
@{N="Datacenter";E={Get-DataCenter -VM $_}}, `
@{N="Cluster";E={Get-Cluster -VM $_}}, `
{ [PSCustomObject] @{ vCenter = $_.Uid.Substring($_.Uid.IndexOf('@')+1).Split(":")[0] } }, `
@{N="ESXi Host";E={Get-VMHost -VM $_}}, `
@{N="Datastore";E={Get-Datastore -VM $_}}, `
@{N="MacAddress";E={[string]::Join(',',($_.Guest.Nics | %{$_.MacAddress}))}}, `
@{N="VLanID";E={[string]::Join('#',(Get-VirtualPortGroup -VM $_ | %{$_.VLanID}))}}, `
@{N="PortGroup";E={Get-VirtualPortGroup -VM $_}}| `
Export-Csv -NoTypeInformation C:\Scripts\VM_CLuster_Host_Datastore_PortGroup_vLANiD.csv
#Stop Script
Stop-Transcript
## Save as CMDB_Report.ps1