Skip Ribbon Commands
Skip to main content

Quick Launch

Todd Klindt's home page > Todd Klindt's Office 365 Admin Blog > Posts > How to Retrieve Passwords Stored in Windows with PowerShell
December 02
How to Retrieve Passwords Stored in Windows with PowerShell

I recently saw a post from someone that had upgraded to Windows 10 and they were lamenting that they had lost some of the saved passwords that Windows had stored. There’s not a man, woman, or dog alive that enjoys typing usernames or passwords. And these days it’s just irresponsible to have a simple password, or the same password for every site you go to. So now you have the burden of remembering them and typing them. Ain’t nobody got time for that! The best solution is to use a Password Manager, of course. I use Password Vault Manager, but there are a bunch of great options out there. It’s just good sense to use one.

But what if you don’t have one and you’re getting ready to upgrade, or do a new install, or I’ve convinced you of the merits of a Password Manager and you want to start moving into one? Do you have to remember all the sites and usernames and passwords? Well, probably not. Windows Control panel gives you a glimpse into the private life of Credentials. Go to the Start Screen and type “Credentials.” That will bring up the Windows Credential Manager.


It will list all the websites that it has saved passwords for. The passwords are hidden by default. You may have to authenticate the first time you click “Show.” For obvious reasons I’m not going to show too much of my own credential store. Smile I don’t need you jokers signing in to my MSDN account and posting “I love Developers” to the MSDN forums.

So if you’re concerned about losing usernames or passwords, you can go into the Credential Manager and copy them out. Great, right? No, not great. So much copying and pasting. So much clicking of “Show.” There must be a better way!

There is…PowerShell.

First, let me say I did not write this code. Someone smarter than me did and I copied it down. If you’re the author of this code, let me know.

This snippet of PowerShell will list out all of the entries in the Credential Manager in an easy to copy and paste manner. Now, obviously, since this is a list of every web site, username, and password you have, be very,very careful with this.

Here is the code:

$vault = New-Object Windows.Security.Credentials.PasswordVault
$vault.RetrieveAll() | % { $_.RetrievePassword();$_ }

Again, I can’t take credit for this. Thanks to whoever did write it. Smile 

I hope this helps some folks recover usernames and passwords, before it’s too late.




works on Win10 too?

on my machine not running :-(

IsPublic IsSerial Name                                  BaseType                 
-------- -------- ----                                     --------                 
True     True     Void                                    System.ValueType         
True     False    PasswordVault                       System.Runtime.InteropS...
 on 12/6/2015 4:57 AM

Re: works on Win10 too?

Yes, I have confirmed that it works on Windows 10. I'm not sure why you're getting the results you are.

Todd O. KlindtNo presence information on 12/6/2015 9:05 AM

Improve Output

Great script / definitely a keeper! I ran it on Windows 10 with no issues.

I added the following to the end of the last command to sort and prevent truncation. 

| select Resource, UserName, Password | Sort-Object Resource | ft -AutoSize

You should probably also export the results to CSV:
| export-csv C:\Export.csv)

 on 12/7/2015 10:49 AM

Re: Improve Output

Hey Don,
Those are good additions. I, too, have done some of that formatting. I didn't add it to my blog post because I didn't want to encourage people to create CSV files with all their passwords in them. :)

Todd O. KlindtNo presence information on 12/7/2015 11:10 AM

Re: Improve Output

I 100% agree about not liking the idea of saving passwords in a csv file, but the use case you started with is that passwords were lost after upgrade (or other event.)  The PowerShell script will not help you if all of your passwords were wiped out. I guess a better answer would include IFI (Instructions for Idiots) to convert the csv into a file format that can be secured and only keep it until you know your passwords made it through the upgrade. :)

 on 12/7/2015 11:44 AM


Script only returns web credentials and not windows credentials
 on 5/19/2017 7:06 AM

Worked for me

The script worked as intended, I got my windows credentials, thanks!
 on 8/26/2017 2:29 PM

Awesome script

This saved so much time, i really wasn't looking forward to going through the credential manager to show passwords.

Thank you, the script is awesome!
 on 9/13/2017 1:10 AM

Need script for windows 7

I tried this on windows 7 machine but only got errors.   Is there a different script for this
 on 9/20/2017 9:39 AM



Nice webpage. 
The script ran, I removed the [Void] in the first line.
The format was slightly altered, perhaps improved.

The Credential Manager listed 2, the script only 1.

So I am intrigued.

The date thing, it not in UK format, US probably.

 on 1/18/2018 8:22 AM
1 - 10Next

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.


Body *

Today's date *

Select a date from the calendar.
Please enter today's date so I know you are a real person


Want a message when I reply to your comment? Put your Twitter handle here.