共用方式為


Get-AuthenticodeSignature

取得檔案之 Authenticode 簽章的相關信息。

語法

ByPath (預設值)

Get-AuthenticodeSignature
    [-FilePath] <String[]>
    [<CommonParameters>]

ByLiteralPath

Get-AuthenticodeSignature
    -LiteralPath <String[]>
    [<CommonParameters>]

Description

Get-AuthenticodeSignature Cmdlet 會取得檔案 Authenticode 簽章的相關信息。 如果未簽署檔案,則會擷取資訊,但字段是空白的。

範例

範例 1:取得檔案的 Authenticode 簽章

Get-AuthenticodeSignature -FilePath "C:\Test\NewScript.ps1"

此命令會取得 NewScript.ps1 檔案中 Authenticode 簽章的相關信息。 它會使用 FilePath 參數來指定檔案。

範例 2:取得多個檔案的 Authenticode 簽章

Get-AuthenticodeSignature test.ps1, test1.ps1, sign-file.ps1, makexml.ps1

此命令會取得命令行所列四個檔案的 Authenticode 簽章相關信息。 在此範例中,會省略 FilePath 參數的名稱,這是選擇性的。

範例 3:只取得多個檔案的有效 Authenticode 簽章

Get-ChildItem $PSHOME\*.* | ForEach-object {Get-AuthenticodeSignature $_} | Where-Object {$_.status -eq "Valid"}

此命令會列出 $PSHOME 目錄中具有有效 Authenticode 簽章的所有檔案。 $PSHOME 自動變數包含PowerShell安裝目錄的路徑。

此命令會使用 get-ChildItem Cmdlet Get-ChildItem 來取得 目錄中的檔案。 它會使用 的模式。 排除目錄(雖然它也會排除檔名中沒有點的檔案)。

命令會使用管線運算符 (|) 將 中的檔案傳送至 ForEach-Object Cmdlet,其中會針對每個檔案呼叫 get-AuthenticodeSignature

Get-AuthenticodeSignature 命令的結果會傳送至只選取狀態為 Valid 之簽章物件的 Where-Object 命令。

參數

-FilePath

指定要檢查之檔案的路徑。 允許使用通配符,但必須指向單一檔案。 當您指定此參數的值時,不需要在命令行輸入 -FilePath

參數屬性

類型:

String[]

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

參數集

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

-LiteralPath

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

參數屬性

類型:

String[]

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

參數集

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

CommonParameters

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

輸入

String

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

輸出

Signature

Get-AuthenticodeSignature 會針對它取得的每個簽章傳回簽章物件。

備註

如需 PowerShell 中 Authenticode 簽章的相關信息,請參閱 about_Signing