First determine whether you are trying to delete the app's password or the certificate key credentials associated with the app.
If you are trying to remove expired key credentials from your app, you will also need to pass the proof
attribute in the request body.
Import-Module Microsoft.Graph.Applications
$params = @{
keyId = "f0b0b335-1d71-4883-8f98-567911bfdca6"
proof = "eyJ0eXAiOiJ..."
}
Remove-MgApplicationKey -ApplicationId $applicationId -BodyParameter $params
If you are trying to remove an app's expired client secret, then you should call the /removePassword
endpoint.
Import-Module Microsoft.Graph.Applications
$params = @{
keyId = "f0b0b335-1d71-4883-8f98-567911bfdca6"
}
Remove-MgApplicationPassword -ApplicationId $appObjectId -BodyParameter $params
Hope this helps.
If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.