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:
The way I see it in the csv is this:
Import in excel:
How can I get this result?
I don't understand why the text doesn't go to a new line.