Author Posts

November 4, 2016 at 6:13 pm

Hello All,
OK here is my situation. I have a text file that contains some sensitive information and I need to scramble that data. In the past I've worked with XML and CSV, which made doing this A LOT easier, but in this situation all I have to work with is a flat text file.
I can pull the data I need and save that to another document. Now the data that needs scrambled lives in certain columns, but for the life off me I cannot figure out how to take the data that I've pulled using this command:

 get-content C:\Temp\ard20161022.txt | select-string -pattern '\d+G ' 

and while it is in memory make the changes to the data that lives at those specific columns.
The first set of data that needs scrambled starts at column 88 and ends at column 105, the second set starts at column 126 and ends at column 146.
Thank you for any help or advice you can offer.

November 4, 2016 at 7:38 pm

No 100% sure I follow you, but try this and see if it leads to a solution.

$x="1234567890"
$y=$x.ToCharArray()
5..7|%{$y[$_] = '*'}
$x = $y -join ''
$x

Just remember that the array is base 0.

November 4, 2016 at 7:43 pm

I'll give that a try.

Thanks!