Is this even possible to do with PowerShell?

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of Tony Tony 1 month ago.

  • Author
    Posts
  • #56926
    Profile photo of Tony
    Tony
    Participant

    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.

  • #56941
    Profile photo of Ron
    Ron
    Participant

    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.

  • #56944
    Profile photo of Tony
    Tony
    Participant

    I'll give that a try.

    Thanks!

You must be logged in to reply to this topic.