Skip to content

Instantly share code, notes, and snippets.

@VimalShekar
Last active October 14, 2021 12:11
Show Gist options
  • Save VimalShekar/7ebf2e8787a1ccab7379902ad7b76fbb to your computer and use it in GitHub Desktop.
Save VimalShekar/7ebf2e8787a1ccab7379902ad7b76fbb to your computer and use it in GitHub Desktop.
Retrieve username and passwords of Web Credentials stored in Credential Manager using PowerShell
#-- Get the full script here : https://github.com/VimalShekar/PowerShell/blob/master/GetCredmanCreds.ps1
#
# Function to read the IE/Edge password vault (Web Credentials portion of credential manager)
#
function Get-PasswordVaultCredentials {
#initilize empty array
$CRED_MANAGER_CREDS_LST = @()
try
{
#Load the WinRT projection for the PasswordVault
$Script:vaultType = [Windows.Security.Credentials.PasswordVault,Windows.Security.Credentials,ContentType=WindowsRuntime]
$Script:vault = new-object Windows.Security.Credentials.PasswordVault -ErrorAction silentlycontinue
$Results = $Script:vault.RetrieveAll()
foreach($credentry in $Results)
{
$credobject = $Script:vault.Retrieve( $credentry.Resource, $credentry.UserName )
$obj = New-Object PSObject
Add-Member -inputObject $obj -memberType NoteProperty -name "Username" -value "$($credobject.UserName)"
Add-Member -inputObject $obj -memberType NoteProperty -name "Hostname" -value "$($credobject.Resource)" # URI need to be sanitised
Add-Member -inputObject $obj -memberType NoteProperty -name "Password" -value "$($credobject.Password)"
$CRED_MANAGER_CREDS_LST += $obj
}
}
catch
{
Write-Host "Failed to instantiate passwordvault class. $($_.InvocationInfo.PositionMessage)"
}
return $CRED_MANAGER_CREDS_LST
}
#Usage:
#Get-PasswordVaultCredentials
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment