Is there a way to retrieve the client secret of an Azure AD application using PowerShell?

Viewed 1402

Is there a way to retrieve the Client Secret from Azure AD Application as a plain text by using PowerShell?

I tried with the below commands, but it is returning only the type of the secret, not the actual value.

$objectID = "00000-00000-00000-00000"
$keyID = "00000-00000-00000-00000"
$secret = Get-AzADAppCredential -ObjectId $objectID | Where-Object {$_.KeyId -eq $keyID}
$secret

enter image description here

1 Answers

You cannot retrieve the value of created Client Secret in any way.

Explanation of secretText:

The generated password value is only returned during the initial POST request to addPassword. There is no way to retrieve this password in the future.

The only way is add new Client Secret and store the new value securely.

$SecureStringPassword = ConvertTo-SecureString -String "password" -AsPlainText -Force
New-AzADAppCredential -ObjectId 1f89cf81-0146-4f4e-beae-2007d0668416 -Password $SecureStringPassword
Related