therealsix
therealsix

Reputation: 654

Secure parameters with powershell exec

I have a Powershell app that retrieves some secret data- then needs to execute a .NET exe (locally) passing that data. It appears that passing the data as a raw param could expose it to users on the machine, so I'm looking for a way to keep it secure.

Possible solutions-

  1. Get the data directly from the C# app (possible, but not ideal)
  2. Put the data in an EFS encrypted file and pass the file location
  3. Encrypt the param with a shared key (something built into windows?)

Any tips/guidance would be appreciated.

Upvotes: 0

Views: 543

Answers (1)

Vasili Syrakis
Vasili Syrakis

Reputation: 9591

Please see this Microsoft Technet article:

Working With Passwords and Secure Strings in Windows Powershell

The gist of the above article:

Basic example of encrypting a string:

$PlainParam = "param you want to encrypt"
$SecureParam = $PlainParam | ConvertTo-SecureString -AsPlainText -Force

Cmdlets to look into:

ConvertTo-SecureString
ConvertFrom-SecureString    

Upvotes: 1

Related Questions