×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How to encrypt a text file with PowerShell

How to encrypt a text file with PowerShell

How to encrypt a text file with PowerShell

(OP)
I have written a script that is used for disk cleanup on a file server. The script looks at user shares, checks with AD to see if the account is disabled and if so checks if the user login exists in a text file that indicates who is on litigation hold. If the account is disabled and not on Litigation Hold, the directory is deleted. All of these features are working great.

I am now trying to find a way to encrypt the file and it is driving me nuts. Has anyone had any success with encrypting and decrypting a file?

I tried reading the file with Get-Content and looped through each line and tried to ConvertTo-SecureString and then append that to a new file but that didn't work. Tried downloading a PGP module but that tells me it can't work with the string data. I am at a loss. I would appreciate it if anyone that has pulled this off could point me in the right direction.

Thank you,

Mark

RE: How to encrypt a text file with PowerShell

RE: How to encrypt a text file with PowerShell

(OP)
Thanks Frederico, I had found that same script and article but couldn't get it to work for my needs. I am able to protect a file, but can't figure out a means to read the encrypted data and unencrypt it in the script without reversing the encryption in the file on disk. The situation requires that the person running the script cannot casually read the contents of the file. I also don't see how you can generate a Key and save it for later use. Any additional pointers you might be able to share?

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Work SMARTER not HARDER.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close