首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >通过Azure PowerShell导入证书期间使用标记时出错

通过Azure PowerShell导入证书期间使用标记时出错
EN

Stack Overflow用户
提问于 2018-09-26 23:41:56
回答 1查看 328关注 0票数 0

问题描述:(请参阅下面的屏幕转储以供参考)使用Import-AzureKeyVaultCertificate cmdlet的标记失败。即使我收到错误消息(如下所示),证书也会正常导入密钥库。但是,我无法使用Get-AzureKeyVaultCertificate cmdlet检索证书,即使我可以使用Get-AzureKeyVaultSecret cmdlet (标记正确显示)。其他信息·如果我从Azure门户网站删除标记或在没有-Tag的情况下重新导入证书,我仍然会收到相同的错误(无法转换对象)。·如果我删除证书并重新导入不带标签的证书,一切正常。

需要帮助:我使用的是5.1.2Azure PowerShell。请告诉我我遗漏了什么。谢谢。

代码语言:javascript
复制
PS C:\Users\tonychou> $certificateTag = @{
    type = "certificate";
    subjectname = "rsppe-microsoft-com";
    alternatename = "dss";
    environment = "Test"
    };

PS C:\Users\tonychou> $certificatePasswordSecuredString = ConvertTo-SecureString $certificatePassword -AsPlainText -Force;
Import-AzureKeyVaultCertificate -VaultName $kvName -CertificateName $certInCertName -FilePath $certificatePfxFile -Password $certificatePasswordSecuredString -Tag $certificateTag;

Import-AzureKeyVaultCertificate : Unable to cast object of type 'System.Collections.Generic.Dictionary`2[System.String,System.String]' to type 'System.Collections.Hashtable'.
At line:2 char:1
+ Import-AzureKeyVaultCertificate -VaultName $kvName -CertificateName $ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Import-AzureKeyVaultCertificate], InvalidCastException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.KeyVault.ImportAzureKeyVaultCertificate

PS C:\Users\tonychou> $certInCertificate = Get-AzureKeyVaultCertificate -VaultName $kvName -Name $certInCertName;
Get-AzureKeyVaultCertificate : Unable to cast object of type 'System.Collections.Generic.Dictionary`2[System.String,System.String]' to type 'System.Collections.Hashtable'.
At line:1 char:22
+ ... rtificate = Get-AzureKeyVaultCertificate -VaultName $kvName -Name $ce ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzureKeyVaultCertificate], InvalidCastException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.KeyVault.GetAzureKeyVaultCertificate

PS C:\Users\tonychou> $certInSecret = Get-AzureKeyVaultSecret -VaultName $kvName -Name $certInCertName;


PS C:\Users\tonychou> $certInCertificate 

PS C:\Users\tonychou> $certInSecret


SecretValue     : System.Security.SecureString
SecretValueText : MIIXegIBAzCCFzoGCSqGSIb3DQEHAaCCFysEghcnMIIXIzCCBgQGCSqGSIb3DQEHAaCCBfUEggXxMIIF7TCCBekGCyqGSIb3DQEMCgECoIIE9jCCBPIwHAYKKoZIhvcNAQwBAzAOBAgn0z9KUgiVSwICB9AEggTQ+38U79mo15qmAm7r0IgpGlveZFMHwqYt/LmEZOUyTKXv6GWHxkSoy/+dsa2XkVFruWas5WgqksMuwxY
                  43kum42JCzSHIkEzAbiN3zZNZWM7JDLaXBooR2bpOR49fdGdy44RmQjFGkU7w2cYLMjB+WSBQ9tt2xw4W1fJnv4d3vO44BQ/c2n1aHBZjmobdSrIDtpK8h+aiZyUrNix6wlifthI884h09rlF6ipBDicbgLn4NbpYPzfZlpa304fU9c7h0j/IDpdOi2zZOVT2Q3oc9ouMuSaKBC9CKE3Q99UBwyX/tZjM/A/uuW5nh3KQZ8
                  IJciW7/odBt3b9venZOHHbAZDns5iIzwop3hzSEDbQTqQ3hffdFEyUexHsq5AP2syveZYWlIrDpe9YJVB 

PS C:\Users\tonychou> Get-Module -ListAvailable | ?{$_.Name -eq "Azure"}


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands                                                                                                                                                                                       
---------- -------    ----                                ----------------                                                                                                                                                                                       
Script     5.1.2      Azure                               {Get-AzureAutomationCertificate, Get-AzureAutomationConnection, New-AzureAutomationConnection, Remove-AzureAutomationConnection...} 
EN

回答 1

Stack Overflow用户

发布于 2018-10-16 03:29:09

我们建议迁移到Powershell版本6.0.0或更高版本

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52521601

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档