Copying/adjusting lines from one file to another.

I’m a newbie, but looking to do the following.

I have a pipe-delimited file with several records in the following format:

A|B| | |1234566789|ABC

I need to find a way to copy each individual line of the file to multiple new lines in a new file while replacing the last value in the line.

Output file for the line above would be:

A|B| | |1234566789|NEWVALUE1

A|B| | |1234566789|NEWVALUE2

A|B| | |1234566789|NEWVALUE3

A|B| | |1234566789|NEWVALUE4

Any help would be greatly appreciated.

 

 

What have you tried so far?
You could treat your pipe delimited file as CSV and use Import-CSV and Export-CSV with some calculated properties to achieve what you need.

It is not really clear what you are after here.
Please show what you have tried, the errors you’ve encountered and the end results you’d expect.

It is confusing when you say “copy each individual line of the file to multiple new lines in a new file while replacing the last value in the line.”
Does one line in the source file creaate multiple lines in a new file?
What determines the new value?

Or is this just a new file with a new last value for each line.
A simple -replace might be all you need depending on your ultimate goal.