首页 > 解决方案 > 关于 cmdlet 'Get-AzKeyVaultSecret' SecretValueText 中的重大更改的警告已弃用 Az4.6.1

问题描述

我今天将 Az Powershell 升级到 4.6.1 并开始看到以下警告。我的问题是我应该如何处理这个警告?我可以将警告静音,但这根本无法帮助我为这种重大变化做好准备。我检查了 Az 4.6.1 Microsoft 文档,他们告诉我我应该仍然使用 SecretValueText,并且没有提供关于弃用或任何其他获取秘密值的方法的类似警告。那么使用 SecretValueText 读取 KeyVault 机密的 powershell 的更新路径是什么?

WARNING: Breaking changes in the cmdlet 'Get-AzKeyVaultSecret' :
WARNING:  - "The output type 'Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultSecret' is changing" 
- The following properties in the output type are being deprecated :
 'SecretValueText'
WARNING: Note :The change is expected to take effect from the version :  '3.0.0'
WARNING:  - "The output type 'Microsoft.Azure.Commands.KeyVault.Models.PSDeletedKeyVaultSecret' is changing"
 - The following properties in the output type are being deprecated :
 'SecretValueText'
WARNING: Note :The change is expected to take effect from the version :  '3.0.0'
WARNING: NOTE : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.

这是Microsoft 文档中的当前示例:

$secret = Get-AzKeyVaultSecret -VaultName 'Contoso' -Name 'ITSecret'
Write-Host "Secret Value is:" $secret.SecretValueText

Secret Value is: P@ssw0rd

标签: azureazure-powershell

解决方案


这可以通过以下方式完成:

通过以下方式获取秘密:

$secret = Get-AzKeyVaultSecret -VaultName {YourVaultName} -Name {YourSecret}
$pass = $secret.SecretValue | ConvertFrom-SecureString -AsPlainText

这与 $secret.SecretValueText 相同


推荐阅读