Encrypt-File

PowerShell script for encrypting the contents of a plain text file.


Prerequisites

Install module FileCryptography.psm1 in same folder location as this script.

https://gallery.technet.microsoft.com/scriptcenter/EncryptDecrypt-files-use-65e7ae5d


I use this script to store the contents of the root token and associated vault keys generated when initializing a Hashicorp Vault server.

Encrypt a file

Encrypt-File Vault-Keys.txt

  Encrypting sensitive data
  The following password is required to decrypt the file, Vault-Keys.txt.zip.AES
  #########################################

The generated password needs to be stored in a secure location.

View Encrypted file

Encrypt-File Vault-Keys.txt -View

  Enter the password key for the encrypted zip file, Vault-Keys.txt.zip.AES
    Key: #####################################

    root: #############################
    key1: ############################################
    key2: ############################################
    key3: ############################################ 
    key4: ############################################
    key5: ############################################

    Enter any key to continue