jt_cp
Contributor
Contributor

VM Note filed

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

0 Kudos
6 Replies
LucD
Leadership
Leadership

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

jt_cp
Contributor
Contributor

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

0 Kudos
LucD
Leadership
Leadership

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

0 Kudos
jt_cp
Contributor
Contributor

Unexpected token 'Join' in expression or statement.

    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordEx

   ception

    + FullyQualifiedErrorId : UnexpectedToken

PowerCLI C:\>

0 Kudos
LucD
Leadership
Leadership

Oops, something went wrong in the copy/paste.

Corrected, try again please


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
jt_cp
Contributor
Contributor

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.

0 Kudos