获取当前导入证书的指纹
Get thumbprint of currently imported certificate
我需要导入证书并获取其指纹。我试过这样的 cmdlet + 管道:
Import-Certificate <parameters> | Get-ItemProperty -Name Thumbprint
但我收到错误 Get-ItemProperty:无法使用接口。此提供程序不支持 IPropertyCmdletProvider 接口。 我每次尝试使用 Get-ItemProperty cmdlet 时都会收到此错误。
而且我不知道如何在脚本中进一步使用它,即使它通过了。因为如果我在它前面放一个变量定义,比如$Thumbprint = Import-Certificate <parameters> | Get-ItemProperty -Name Thumbprint
,我想它不会真正将证书导入商店,而只是将它存储到变量中,对吗?
我需要使用 PowerShell v4
我相信,您想使用 Select-Object
而不是 Get-ItemProperty
:
Import-Certificate <parameters> | Select-Object Thumbprint
但如您所料,Import-Certificate
将证书导入到本地证书存储区。如果您想查看证书而不在任何地方安装它,请使用以下语法:
New-Object Security.Cryptography.X509Certificates.X509Certificate2 $path | Select-Object Thumbprint
我需要导入证书并获取其指纹。我试过这样的 cmdlet + 管道:
Import-Certificate <parameters> | Get-ItemProperty -Name Thumbprint
但我收到错误 Get-ItemProperty:无法使用接口。此提供程序不支持 IPropertyCmdletProvider 接口。 我每次尝试使用 Get-ItemProperty cmdlet 时都会收到此错误。
而且我不知道如何在脚本中进一步使用它,即使它通过了。因为如果我在它前面放一个变量定义,比如$Thumbprint = Import-Certificate <parameters> | Get-ItemProperty -Name Thumbprint
,我想它不会真正将证书导入商店,而只是将它存储到变量中,对吗?
我需要使用 PowerShell v4
我相信,您想使用 Select-Object
而不是 Get-ItemProperty
:
Import-Certificate <parameters> | Select-Object Thumbprint
但如您所料,Import-Certificate
将证书导入到本地证书存储区。如果您想查看证书而不在任何地方安装它,请使用以下语法:
New-Object Security.Cryptography.X509Certificates.X509Certificate2 $path | Select-Object Thumbprint