Get-PfxCertificate

取得電腦上 PFX 憑證檔案的資訊。

語法

ByPath (預設值)

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

ByLiteralPath

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

Description

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

範例

範例一:取得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 憑證檔案未受密碼保護時,認證Invoke-Command值必須為 CredSSP。

參數

-FilePath

指定安全檔案 PFX 檔案的完整路徑。 如果你指定這個參數的值,就不需要 -FilePath 在命令列輸入。

參數屬性

類型:

String[]

預設值:None
支援萬用字元:False
不要顯示:False

參數集

ByPath
Position:0
必要:True
來自管線的值:True
來自管線按屬性名稱的值:True
來自剩餘引數的值:False

-LiteralPath

安全檔案的完整路徑指向 PFX 檔案。 與 FilePath不同,LiteralPath 參數的值會被完全按其鍵入方式使用。 不會將任何字元解譯為通配符。 如果路徑包含逸出字元,請以單引弧括住它。 單引號會告知PowerShell不要將任何字元解譯為逸出序列。

參數屬性

類型:

String[]

預設值:None
支援萬用字元:False
不要顯示:False
別名:PSPath, LP

參數集

ByLiteralPath
Position:Named
必要:True
來自管線的值:False
來自管線按屬性名稱的值:True
來自剩餘引數的值:False

-NoPromptForPassword

會抑制提示輸入密碼。

參數屬性

類型:SwitchParameter
預設值:None
支援萬用字元:False
不要顯示:False

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

-Password

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

此參數於 PowerShell 6.1 中引入。

Note

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

參數屬性

類型:SecureString
預設值:None
支援萬用字元:False
不要顯示:False

參數集

(All)
Position:Named
必要:False
來自管線的值:False
來自管線按屬性名稱的值:False
來自剩餘引數的值:False

CommonParameters

此 cmdlet 支援常見參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters。

輸入

String

你可以將包含檔案路徑的字串管道傳送到 Get-PfxCertificate。

輸出

X509Certificate2

Get-PfxCertificate 會為每個憑證回傳一個物件。

備註

當使用 Invoke-Command cmdlet 遠端執行 Get-PfxCertificate 指令,且 PFX 憑證檔案未設密碼保護時, AuthenticationInvoke-Command 參數的值必須為 CredSSP。