Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing Windows Credential Manager from PowerShell

I'm using PowerShell 2.0 (necessary because of SP2010) On Windows Server 2008 R2. I need to retrieve credentials for a process from the Windows Credential Manager. I can't seem to make it work.

I was given this piece of code:

[Windows.Security.Credentials.PasswordVault,Windows.Security.Credentials,ContentType=WindowsRuntime] (new-object Windows.Security.Credentials.PasswordVault).RetrieveAll() | % { $_.RetrievePassword(); $_ } 

both lines of code throw errors

Windows.Security.Credentials.PasswordVault,Windows.Security.Credentials,ContentType=WindowsRuntime : Unable to find type [Windows.Security.Credentials.PasswordVault,Windows.Security.Credentials,ContentType=WindowsRuntime]: make sure that the assembly containing this type is loaded. 

and

(new-object Windows.Security.Credentials.PasswordVault).RetrieveAll() | % {$_.RetrievePassword(); $_ }  

respectively. I've been trying to somehow import the PasswordVault class. So far Google has failed me, I haven't even been able to find out which assembly it resides in. What am I missing?

like image 229
Shaggydog Avatar asked Mar 17 '15 15:03

Shaggydog


People also ask

How do I get Windows credentials in PowerShell?

You can use the credential object in security operations. The Get-Credential cmdlet prompts the user for a password or a user name and password. You can use the Message parameter to specify a customized message in the command line prompt.

How do I retrieve my Windows Credential Manager password?

If you need to see the list of your credentials, you may go to Control Panel > User Accounts > Credential Manager. You may click the dropdown arrow then click Show on Password field. Please note that it will ask you to re-enter the password to verify your identity.

Where are Credential Manager passwords stored?

As part of Credentials from Web Browsers, Internet Explorer and Microsoft Edge website credentials are managed by the Credential Manager and are stored in the Web Credentials locker. Application and network credentials are stored in the Windows Credentials locker.


1 Answers

In powershell5 type:

   Install-Module CredentialManager -force 

Then

   New-StoredCredential -Target $url -Username $ENV:Username -Pass .... 

and later

   Get-StoredCredential -Target ....  

Source code for the module is https://github.com/davotronic5000/PowerShell_Credential_Manager

like image 60
majkinetor Avatar answered Sep 24 '22 09:09

majkinetor