adding text after a line

Welcome Forums General PowerShell Q&A adding text after a line

This topic contains 1 reply, has 1 voice, and was last updated by

 
Participant
1 year ago.

  • Author
    Posts
  • #83221

    Participant
    Points: 53
    Rank: Member

    I'm trying to add the word "br" in a text file, but it's not adding.

    if ($employees.Title -eq "NULL") {
            (Get-Content $public_html_files\$txt_file_names) | Where-Object {$_ -notmatch "TITLE"}  | Set-Content $public_html_files\$txt_file_names -Force        
            $add_break = Get-Content $public_html_files\$txt_file_names
            $add_break[5] += "br"
    }
  • #83233

    Participant
    Points: 53
    Rank: Member

    I figured it out, thank you

    if ($employees.Title -eq "NULL") {
            (Get-Content $public_html_files\$txt_file_names) | Where-Object {$_ -notmatch "TITLE"} | Set-Content $public_html_files\$txt_file_names -Force        
            $add_break = Get-Content $public_html_files\$txt_file_names
            $add_break[5] += ""
            $add_break | Set-Content $public_html_files\$txt_file_names -Force                
        }

The topic ‘adding text after a line’ is closed to new replies.