Hi, you could try piping to the Export-Csv cmdlet:
...... | Export-Csv C:\PathToCSVFile
Good luck!
try this:
$vmList = Get-Content -Path C:\VMs.txt
foreach ($vm in $vmList)
{
get-vm $vm| %{ write-host $_.Name `t ($_ | Get-VirtualPortGroup | select vlanid)} | export-csv -useculture -notypeinformation -path c:\network.csv
}
Not working. Creating blank output file. Can see the output in command prompt.
The script is using Write-Host, which means that the output is written to the console (essentially being dropped) and can't be piped to the next command (ie. the export cmdlet).
You could try Write-Output instead of Write-Host but I would be inclined to rewrite the script (but only because I would find it easier to follow with custom columns).
Cheers,
Jon