For some reason this script is only reporting on the last vm in the csv. Most likely my incorrect use of the first "foreach". Any help would be appreciated.
$curvc = read-host -prompt "Enter VC Name"
connect-viserver -server $curvc
$vms = Import-CSV .\name_dev.csv
foreach ($vm in $vms) {Get-VM $vm.Name |
foreach {
$Report = "" | Select-Object -property Name,NumCpu,MemoryMB,Host
$Report.Name = $_.Name
$Report.NumCpu = $_.NumCpu
$Report.MemoryMB = $_.MemoryMB
$Report.Host = $_.VMHost
Write-Output $Report
} | Export-Csv ".\VM.csv"
}
disconnect-viserver * -confirm:$false