Get-StoredCredentials Module

June 7, 2013
Powershell Security

Password Vault'

If you’re doing security right, the credential you use to log into your workstation is not the same used to managed the Production environment. Because of that practice, I have to run Get-Credential almost every time I open up a new Powershell session and type in details manually. There are plenty of options for storing credentials securely and one has been standard in Windows for over a decade—Windows Credential Manager. Why has no one built a script for getting and setting credentials from this store? Well, it’s exposed through a Win32 API. For all my searching I could not find a .Net class for working with it or even an open source .Net wrapper. There’s just this example code. Fortunately, a few people have pieced together the interesting bits to get credentials out of the Credential Manager. I cleaned up the code a bit and made it a Script Module so it will auto-load when I type the alias gsc.

The next step will be to build a proxy function that wraps the native Get-Credential so you can get a new PSCredential via the normal prompt or from the Credential Manager store with a single Cmdlet.

Here’s the source:

comments powered by Disqus