I'm trying to put in multiple lines in Notes field for VMs and exporting it to excel in table format but ran into couple of issues,
1) exported file contains only first line if I use FT instead of FL
2) line gets truncated even with -autosize and Out-String 2048.
VM Notes:
line1: Exchange-PrimarySite-CAS/HT handled by Joe on Mon and Mo on Thursday and for other days good luck test description *
line2:
line3: Critical_Server * Handled_by_Site1 *
line4:
line5: 1st_Tier
get-vm exchange1 | ft name,notes -autosize | out-string 2048 | out-file temp.txt
You are mixing cmdlets that format console output with the CSV export.
Try
Get-VM -Name Exchange1 | Select Name,Notes | Export-Csv report.csv -NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks for the reply. The exported CSV file only contain the first line in Notes field. Line 3 and line 5 is missing.
VM Notes:
line1: Exchange-PrimarySite-CAS/HT handled by Joe on Mon and Mo on Thursday and for other days good luck test description *
line2:
line3: Critical_Server * Handled_by_Site1 *
line4:
line5: 1st_Tier
Can you try
Get-VM -Name Exchange1 | Select Name,@{N="Notes";E={[string]::Join(',',$_.Notes)}} | Export-Csv report.csv -NoTypeInformation
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Unexpected token 'Join' in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordEx
ception
+ FullyQualifiedErrorId : UnexpectedToken
PowerCLI C:\>
Oops, something went wrong in the copy/paste.
Corrected, try again please
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Interesting, after manually replacing the note field, the entire notes are exported. Perhaps something strange about different version of vSphere after all the upgrades through time.