Add-PSSnapin -Name *vmware*
$date = get-date -UFormat %y%m%d
$vcenterlist = "vcenter1","vcenter2","vcenter3","vcetner4"
$username = Read-Host("input your vcenter username:" )
$passwd = Read-Host("input your vcenter administrator password:" )
foreach ($vcenter in $vcenterlist){
    Connect-VIServer $vcenter -User $username -Password $passwd | Out-Null
    get-vm | Select-Object Name, PowerState,VMhost, MemoryGB, NumCpu, @{ n="DiskUsedGB"; e={[math]::round( $_.UsedSpaceGB )}},
                                                                            @{N="CapacityGB";E={$_.HardDisks.CapacityGB}},
                                                                            @{N="IPAddress";E={@($_.guest.IPAddress[0])}},
                                                                            @{N="State";E={$_.Guest.State}},
                                                                            @{N="OS";E={$_.Guest.OSFullName}},
                                                                            @{N="Version";E={$_.Version}},
                                                                            @{N="Notes";E={$_.Notes}} | Export-Csv  -NoTypeInformation -Encoding OEM .\desktop\"$vcenter"_"$date".csv 
                                                                            }

Write-Host  '执行完毕,按任意键退出...'
Read-Host