Get current user’s credentials object in Powershell without prompting

The Windows API will not expose the information you need, which is why Powershell can’t get to them. Its an intentional feature of the security subsystem. The only way for this to work is for the Linux machines to trust the calling machine, such as joining them to an Active Directory (or any kerberos setup really).

Aside from that, you’d need to store and pass this information somehow.

You could store the RSA key in the user’s keystore and extract it at runtime (using the .NET Crypto/Keystore libs), so you aren’t storing the key around with the code. That way the key itself would be protected by the OS and available only when the calling user was authenticated. You’d have one more thing to install, but may be the only way to achieve what you are aiming for.

Leave a Comment