Azurecli获得过期的保险库秘密

发布于 2025-02-14 01:23:53 字数 364 浏览 0 评论 0原文

有没有办法使用CLI列出来自Azure密钥库中的所有过期秘密? 到目前为止,我已经向

az keyvault secret list --vault-name <MyVault> --output table --query [*].'{"Id":id,"expires":attributes.expires}'

我展示了一个清单

| id |到期|

| key1 | 2022-07-08 1200 |

| key2 | 2022-01-01 1200 |

我希望能够在属性上设置条件。 属性。Expires&lt; getDate()

,因此仅返回key2

Is there a way to list all expired secrets from an Azure Key Vault using the CLI?
So far I have

az keyvault secret list --vault-name <MyVault> --output table --query [*].'{"Id":id,"expires":attributes.expires}'

This shows me a list

| Id | expires |

|Key1 | 2022-07-08 1200|

|Key2 | 2022-01-01 1200|

I want to be able to set a condition on attributes.expires like
attributes.expires < GetDate()

And therefore only return Key2

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

逆光下的微笑 2025-02-21 01:23:53

您可以在这里找到完整的文档:

这是一个PowerShell样本,可以查询所有已过期秘密:

$vaultName = "<vault-name>"
$today = Get-Date -Format "yyyy-MM-dd"

az keyvault secret list `
  --vault-name $vaultName `
  --query "[?attributes.expires <= '$today'].{Id:id, expires:attributes.expires}"

You can find full documentation here:

Here is a PowerShell sample to query all expired secrets:

$vaultName = "<vault-name>"
$today = Get-Date -Format "yyyy-MM-dd"

az keyvault secret list `
  --vault-name $vaultName `
  --query "[?attributes.expires <= '$today'].{Id:id, expires:attributes.expires}"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文