How to move the text on the same cell ?

Андрей Михалевский 3,426 Reputation points
2022-12-14T13:15:28.03+00:00

Hi. I have script:

$WORD_KEY1 = "Some messages were not copied for odd reasons..."  
$WORD_KEY2 = "message(s) copied"  
$WORD_KEY3 = "concurrent"  
$WORD_KEY4 = "failed"  
  
$myObject = @();  
  
$Output = (($Filename = ( Get-ChildItem -Path "C:\PS\1.txt" -Recurse )) | Select-String -Pattern "$WORD_KEY1|$WORD_KEY2|$WORD_KEY3|$WORD_KEY4")  
  
$box = "mihalevskiy"  
$date = "20.12.2021"  
  
$myObject += [PSCustomObject]@{ 'box' = $box; 'date' = $date; 'String' = [string]($Output.Line -join "`n") }  
  
$myObject | ft -Wrap -AutoSize  
  
$myObject |Select String | Export-Csv -Path "C:\PS\1.csv" -NoTypeInformation  

File:

dst< (\Draft \Recent) "18-Oct-2022 11:  
dst> + Send the additional command text  
dst< (\Draft \Recent) "20-Oct-2022 13:11:05 +0300" (PROPOSENEWUID(331)) {42074}\r\n  
dst> + Send the additional command text  
dst< (\Draft \Recent) "26-Oct-2022 16:43:43 +0300" (PROPOSENEWUID(346)) {43299}\r\n  
dst> + Send the additional command text  
dst< (\Draft \Recent) "31-Oct-2022 13:  
dst> + Send the additional command text  
dst< (\Seen \Draft \Recent) "31-Aug-2022 13:25:29 +0300" (PROPOSENEWUID(485)) {364149}\r\n  
dst> + Send the additional command text  
dst< (\Draft \Recent) "29-Aug-2022 17:34:35 +0300" (PROPOSENEWUID(486)) {80563}\r\n  
dst> + Send the additional command text  
dst< (\Seen \Draft \Recent) "16-Nov-2022 12:19:00 +0300" (PROPOSENEWUID(594)) {775}\r\n  
dst> + Send the additional command text  
dst< \r\n  
dst> * 9 EXISTS  
dst> * 9 RECENT  
dst> a OK [APPENDUID 417147535 1,2,3,4,5,6,7,8,9] APPEND completed  
c: queue=@ size-@  
c: done  
dst< . store 1 +FLAGS.STLENT ($Forwarded)\r\n  
dst> . OK completed  
dst< . store 1 -FLAGS.SILENT ($Forwarded)\r\n  
dst> . OK completed  
dst< . CLOSE\r\n  
dst> . OK completed  
(&BCcENQRABDOEPgQyBDgEOgQ4-) copying complete  
9 messages copied, 643Kb, 1s123ms  
src fetch / dst append time: 3m52s / 30s504ms  
Uptime: 4m@1s  
dst: Disconnecting  
dst< . logout\r\n  
dst> * BYE CommuniGate Pro IMAP Server closing connection  
dst> . OK completed  
src: Disconnecting  
src< . logout\r\n  
src> * BYE Microsoft Exchange Server 2016 IMAP4 server signing off.  
src> . OK LOGOUT completed.  
Some messages were not copied for odd reasons...  
1756 message(s) copied, 432126Kb total, 4m@1s  
src fetch / dst append time: 3m52s / 30s504ms  
src / dst select time: @s906ms / @s179ms  

I need to find certain lines in the file and write them into the file.

I get the right result:

270524-screenshot-10.png

The way I see it in the csv is this:

270490-screenshot-11.png

Import in excel:

270555-screen-12.png

How can I get this result?

270489-screenshot-13.png

I don't understand why the text doesn't go to a new line.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,628 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 47,786 Reputation points
    2022-12-14T19:53:19.26+00:00

    After you import the CSV into Excel, increase the height of the row and the text should wrap whey you inserted the NewLine character.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.