Get-PfxCertificate
取得計算機上 PFX 憑證檔案的相關信息。
語法
ByPath (預設值)
Get-PfxCertificate
[-FilePath] <String[]>
[-Password <SecureString>]
[-NoPromptForPassword]
[<CommonParameters>]
ByLiteralPath
Get-PfxCertificate
-LiteralPath <String[]>
[-Password <SecureString>]
[-NoPromptForPassword]
[<CommonParameters>]
Description
Get-PfxCertificate Cmdlet 取得一個物件,表示每個指定的 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 憑證檔案不受密碼保護時, 的 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 |
參數集
ByLiteralPath
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-NoPromptForPassword
隱藏提示輸入密碼。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Password
指定存取 .pfx 憑證檔案所需的密碼。
此參數是在 PowerShell 6.1 中引進的。
備註
如需 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 憑證檔案不受密碼保護時,Invoke-Command 參數的值必須是 CredSSP。