set-content to WriteALL

Welcome Forums General PowerShell Q&A set-content to WriteALL

This topic contains 0 replies, has 1 voice, and was last updated by  NeVe2994 1 month, 3 weeks ago.

  • Author
    Posts
  • #168991

    Participant
    Topics: 1
    Replies: 0
    Points: 14
    Rank: Member

    Hello,

    first of all I'm neither a Powershell-Pro nor a programming expert. Anyhow I need help.

    Person related Data is XXXX:

    MARIS|DOC|XXXXX|GYN endgl. Brief ambulante OP|XXXXX|XXXX|8228284|1889286|XXXXXX12|XXXXX|null||null|20190719|ZWMAMB

    What I Want:

    Replace first 'null' with '200088'

    AND

    If Text includes word 'SAMPLEWORD' replace 'null' with SAMPLEWORD'

    Sampleword can differ from file to file.

    Alle Files are in one folder, so the scripts needs to relate for all files in one folder.

    With some help I was able to create following Powershell Code:

    
    Get-ChildItem "C:\Users\gemuendadm\Desktop\PGTEST123\*" -File -Include *.txt,*.dat | %{
    $csv = Import-CSV $_.Fullname -Delimiter "|" -Encoding Default -Header (1..15)
    $csv.11 = "200088"
    $csv.13 = $csv.'4'.split(" ")[0]
    ($csv | convertto-csv -Delimiter "|" -NoTypeInformation | select -skip 1) -replace '"',"| sc -Path ($_.Fullname -replace "\.txt$",".dat")
    if ($_.Extension -eq ".txt"){del $_.Fullname -Force}
    }
    
    

     

    Problem: Now there is a page break at the end of the filecontent. Is there any chance to avoid that? Or do I have to use WriteAll?

    If so, can anyone help me transforming my code to WriteAll? I really have no clue.

    Thank you in advance. Would be very kind.

You must be logged in to reply to this topic.