Azure Key Vault:使用PowerShell

时间:2018-02-03 14:55:10

标签: azure powershell azure-keyvault

我正在尝试运行以下PS脚本来备份特定Azure Key Vault中的所有秘密:

$secret = Get-AzureKeyVaultSecret –VaultName 'testkeyvault-1' |
ForEach-Object {
$Name = $_."Name"
Backup-AzureKeyVaultSecret -Secret $Name -OutputFile 'C:\Backup.blob'
}

虽然以下PS错误导致失败,但我们将不胜感激任何帮助:

Backup-AzureKeyVaultSecret : Cannot bind parameter 'Secret'. Cannot convert  the "SQLSecret" value of type "System.String" to type    "Microsoft.Azure.Commands.KeyVault.Models.Secret".
At line:4 char:36
+ Backup-AzureKeyVaultSecret -Secret $Name -OutputFile 'C:\Backup.blob'
+                                    ~~~~~
+ CategoryInfo          : InvalidArgument: (:) [Backup- AzureKeyVaultSecret], ParameterBindingException
+ FullyQualifiedErrorId :  CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.KeyVault.BackupAzureKeyVaultSecret

2 个答案:

答案 0 :(得分:1)

试试这个:

[string]$VaultName = 'testkeyvault-1'
Get-AzureKeyVaultSecret –VaultName $VaultName |
    ForEach-Object {
        Backup-AzureKeyVaultSecret `
            –VaultName $VaultName `
            -Name $_."Name" `
            -OutputFile ('C:\Backup_{0}.blob' -f $_."Name")
    }

相关文档:

答案 1 :(得分:0)

您在LOOP中缺少参数“保险柜名称”