Get-PfxCertificate

取得計算機上 PFX 憑證檔案的相關信息。

Syntax

Get-PfxCertificate
   [-FilePath] <String[]>
   [-Password <SecureString>]
   [-NoPromptForPassword]
   [<CommonParameters>]
Get-PfxCertificate
   -LiteralPath <String[]>
   [-Password <SecureString>]
   [-NoPromptForPassword]
   [<CommonParameters>]

Description

Cmdlet Get-PfxCertificate 會取得物件,代表每個指定的 PFX 憑證檔案。 PFX 檔案同時包含憑證和私鑰。

範例

範例 1:取得 PFX 憑證

Get-PfxCertificate -FilePath "C:\windows\system32\Test.pfx"

Password: ******
Signer Certificate:      David Chew (Self Certificate)
Time Certificate:
Time Stamp:
Path:                    C:\windows\system32\zap.pfx

此命令會取得系統上 Test.pfx 憑證檔案的相關信息。

範例 2:從遠端電腦取得 PFX 憑證

Invoke-Command -ComputerName "Server01" -ScriptBlock {Get-PfxCertificate -FilePath "C:\Text\TestNoPassword.pfx"} -Authentication CredSSP

此命令會從 Server01 遠端電腦取得 PFX 憑證檔案。 它會使用 Invoke-Command 遠端執行 Get-PfxCertificate 命令。

當 PFX 憑證檔案不受密碼保護時,的 Authentication 參數 Invoke-Command 值必須是 CredSSP。

參數

-FilePath

指定受保護檔案之 PFX 檔案的完整路徑。 如果您指定此參數的值,就不需要在命令列輸入 -FilePath

Type:String[]
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-LiteralPath

受保護檔案之 PFX 檔案的完整路徑。 與 FilePath 不同,LiteralPath 參數的值會與輸入時完全相同。 不會將任何字元解譯為通配符。 如果路徑包含逸出字元,請以單引弧括住它。 單引號會告知PowerShell不要將任何字元解譯為逸出序列。

Type:String[]
Aliases:PSPath
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-NoPromptForPassword

隱藏提示輸入密碼。

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Password

指定存取 .pfx 憑證檔案所需的密碼。

此參數是在 PowerShell 6.1 中引進的。

注意

如需 SecureString 數據保護的詳細資訊,請參閱 SecureString 有多安全?

Type:SecureString
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

輸入

String

您可以使用管線將包含檔案路徑的字串傳送至 Get-PfxCertificate

輸出

X509Certificate2

Get-PfxCertificate 會針對它取得的每個憑證傳回 物件。

備註

使用 Invoke-Command Cmdlet 從遠端執行Get-PfxCertificate命令,且 PFX 憑證檔案不受密碼保護時,的 Authentication 參數Invoke-Command必須是 CredSSP。