-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get-AzKeyVaultSecret: Operation get is not allowed on a disabled secret #15378
Comments
Thanks for reporting. We will look into it. |
I am using AzurePowershell Task 5.x in Azure Pipelines. I want to get only enabled secrets and name of the disabled secrets (so that we will know what are disabled) |
@BethanyZhou thanks for your response. I can get the secret names status (true or false) using Get-AzKeyVaultSecret -VaultName $(keyVaultName) with azure powershell version 6.1.0 (specific version), but it doesn't skip disabled secrets. Entire pipeline fails. Here is my code: Am I missing any parameter? Get-AzKeyVaultSecret -VaultName $(keyVaultName) -AsPlainText | Foreach-Object { |
Hi @ktdixit , Thanks for sharing further information. I believe the error is from As you said you only want to get the name of disable secrets, I suggest following code: Get-AzKeyVaultSecret -VaultName $(keyVaultName) | Foreach-Object {
if($_.Enabled){
$secret = Get-AzKeyVaultSecret -VaultName $(keyVaultName) -Name $_.Name -AsPlainText
@{"Value" = $secret; "Name" = $_.Name}
}else{
@{"Value" = "None"; "Name" = $_.Name}
}
} |
@BethanyZhou works perfectly fine. Thank you so much for your help. Much appreciated |
Get-AzKeyVaultSecret -VaultName $keyVaultName
Error:
2021-06-30T12:20:46.1348367Z ##[error]Operation returned an invalid status code 'Forbidden'
Code: Forbidden
Message: Operation get is not allowed on a disabled secret.
2021-06-30T12:20:46.3023398Z ##[error]PowerShell exited with code '1'.
Note: I am running this command in AzureDevOps (Azure Powershell) which has Get, List, Set permission in Keyvault access policies (PermissionsToKeys and PermissionsToSecrets)
The text was updated successfully, but these errors were encountered: