Last active
July 15, 2025 06:41
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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