VMware Cloud Community
miguelvelezwhit
Enthusiast
Enthusiast

How to word wrap a field - possibly via Export-CSV or other method in PowerShell/PowerCLI

OK Gang:

I believe I have a true headscratcher for the day.  Here's the 411:

LucD has been assisting me with my meager PowerShell skills and he's giving me a serious tutorial in calculated fields   Sometimes the old @{  } or the E={ or     @($_  } can really throw me - but i digress.


I'm getting the information that I need, but now there's the issue of how the output comes.  The majority of the time, I use the Export-CSV so that I can ultimately import it into Excel and provide whatever tables my colleagues need at the time.  However, many times I run into a situation like this:

The output from an Export-CSV, right after being pulled into Excel:

  

FDR097P10.2.4.97Symantec XXXXXX
FDDVG125P10.2.4.1251XXXXXXXXXXXX
FDR2VG120P10.2.3.135XXXXXXXX Server to become New PVWA
NetApp Performance Manager10.2.0.100,fe80::250:56ff:feac:b35eOnCommand Performance Manager - Performance troubleshooting for NetApp FAS Series
For more information or support please visit http://www.netapp.com
TBCSR04172.24.240.70,172.24.240.208XXXXXXXXXXXXXXXXXX
FDDVG121D10.2.3.121SAP Mobility/Agentry DEV
NetApp Unified Manager10.2.0.99,fe80::250:56ff:feac:7d6dOnCommand Unified Manager - Application to monitor and manage NetApp storage systems.
For more information or support please visit http://www.netapp.com

My problem resides in Rows 4 and 7.  Instead of the VM name, information from Row 3 column 3 has made it's way into that field (cell).  Or the problem is that data in row 4 column 3 was so massive, that it overwrote the data in the same row, but Column 1..This was a direct output I received after my script ran and the results place in Export-CSV.  I don't know if the problem is in the Export-CSV or if it's somewhere else.  I keep thinking that there may be some type of field limit for the 3rd column (Notes - pulled from Notes field via Get-VM).  Is the error because I haven't included a parameter which would allow the data in field (column) 3 to word wrap?  Or is it some parameter that's missing from the Export-CSV command which would allow each field (or a specific field) to word wrap?

I appreciate any insight/guidance that anyone can share.  I scoured Google and MSDN for a method, but I can't find one.  Hopefully, one of you already has.

TIA,
Miguel    :smileyconfused:Smiley Sad:smileyangry:

0 Kudos
1 Reply
LucD
Leadership
Leadership

This might be an Excel thing.

It would be useful to see what exactly is in column 3 for the rows 4 and 7.

Can you do a, provided the result is in a variable named $report, the following command: $report | Format-List


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

0 Kudos