Skip to content

Instantly share code, notes, and snippets.

@bizouarn
Last active July 15, 2025 06:41
Show Gist options
  • Save bizouarn/22c69a12c787908ebcf8ed5b39a024d5 to your computer and use it in GitHub Desktop.
Save bizouarn/22c69a12c787908ebcf8ed5b39a024d5 to your computer and use it in GitHub Desktop.
Récupère un access_token en clair depuis le Credential Manager Windows
Install-Module -Name CredentialManager -Scope CurrentUser
if (-not $args[0]) {
Write-Error "Usage : ReadCredentialManagerToken.ps1 <NomDuCredential>"
exit 1
}
# Charge le credential
$credential = Get-StoredCredential -Target $args[0]
# Vérification
if ($credential) {
# Conversion du SecureString en string clair
$plainPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto(
[Runtime.InteropServices.Marshal]::SecureStringToBSTR($credential.Password)
)
Write-Output "Token récupéré : $plainPassword"
} else {
Write-Output "Aucun identifiant trouvé."
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment