If you need to access credentials (saved passwords) stored by the Windows Credential Manager, the “CredentialManager” module may be helpful for you. Run this to download and install it:
Install-Module -Name CredentialManager -Scope CurrentUser
Once the module is installed, you can list the new commands it provides:
PS> Get-Command -Module CredentialManager CommandType Name Version Source ----------- ---- ------- ------ Cmdlet Get-StoredCredential 2.0 CredentialManager Cmdlet Get-StrongPassword 2.0 CredentialManager Cmdlet New-StoredCredential 2.0 CredentialManager Cmdlet Remove-StoredCredential 2.0 CredentialManager
Get-StoredCredential dumps the stored credentials. And New-StoredCredential can store a credential with the credential manager for you:
New-StoredCredential -Target MyCred -Credentials (Get-Credential) -Type Generic -Persist LocalMachine
Now, whenever your script needs access to the stored credential, use Get-StoredCredential like this:
$cred = Get-StoredCredential -Target MyCred # show clear text information $cred.UserName $cred.GetNetworkCredential().Password
The Windows Credential Manager safely stores credentials for the local user. Only the user who originally saved the credential can retrieve it.