ReadCredentialManagerToken.ps1
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é."
}