How can I get a C# console application to return a securestring as output to a powershell console

115 Views Asked by At

I need to build a C# console application that will allow me to pass in a string, convert it to a secure string, and pass it out to PowerShell

The reason for this is that we have PowerShell event logging enabled in our environment. When you use the function ConvertTo-SecureString, the clear text password gets logged in the Event log which is a security issue.

I have the code that will accept a string input, and convert it to a securestring, but I cannot find a way to return a securestring. Most ideally, it would instead create an encrypted string like ConvertFrom-Securestring does in PowerShell.

I cannot seem to find a way to do this, but I am still digging into it

0

There are 0 best solutions below