Managing Cached Credentials with PSCredentialManager In the previous tip we talked about a public module called PSCredentialManager that helps you manage cached credentials. Sometime, less...
Managing Cached Credentials with PSCredentialManager
In the previous tip we talked about a public module called PSCredentialManager that helps you manage cached credentials. Sometime, less is more, so when you look at the code you’ll soon discover that it is a console command called cmdkey.exe that actually interacts with Windows.
Listing Cached Credentials with cmdkey.exe
To get a list of cached credentials on your local machine, all you really need is this:
PS> cmdkey /list
Currently stored credentials:
Target: MicrosoftAccount_target=SSO_POP_User
Type: Domain Extended Credentials
User: XXXXX.com
Saved for this logon only
Target: MicrosoftAccount_target=SSO_POP_Device
Type: Domain Extended Credentials
User: 06jbdrfztrwsvsb
Saved for this logon only
...
The output is plain text. However, PowerShell can convert the raw data using the ForEach-Object:
Type User Info Target
---- ---- ---- ------
Domain Extended Credentials [email protected] Saved for this logon only Mi
Domain Extended Credentials 02jbqxcbqvsb Saved for this logon only Mi
Generic [email protected] Local machine persistence Le
Generic Local machine persistence Le
Generic Local machine persistence Le
Generic Local machine persistence Le
Generic [email protected] Local machine persistence Le
Generic Local machine persistence Le
Generic 02jdrxcbqvsb Local machine persistence Wi
Generic Martin Le
Domain Password Martin Do
Domain Password Martin Do
Domain Password User Do