取得檔案中 Authenticode 簽章的相關資訊。

語法

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

描述

Get-AuthenticodeSignature Cmdlet 會取得檔案中 Authenticode 簽章的相關資訊。如果檔案未經簽署,仍會擷取資訊,但是其欄位為空白。

參數

-FilePath <string[]>

指定要檢查之檔案的路徑。允許使用萬用字元,但解析結果必須是單一檔案。參數名稱 ("FilePath") 為選擇項。

必要?

true

位置?

1

預設值

接受管線輸入?

true (ByValue, ByPropertyName)

接受萬用字元?

false

<CommonParameters>

這個 Cmdlet 支援一般參數:-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer 和 -OutVariable。如需詳細資訊,請參閱 about_Commonparameters.

輸入和輸出

輸入型別是可經由管道輸出至 Cmdlet 的物件型別。傳回型別則是 Cmdlet 所傳回的物件型別。

輸入

System.String

您可經由管道將包含檔案路徑的字串輸出至 Get-AuthenticodeSignature。

輸出

System.Management.Automation.Signature

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

附註

如需 Windows PowerShell 中 Authenticode 簽章的詳細資訊,請參閱 about_Signing。

範例 1

C:\PS>get-AuthenticodeSignature -filepath C:\Test\NewScript.ps1

描述
-----------
這個命令會在 NewScript.ps1 檔案中取得 Authenticode 簽章的相關資訊。它會使用 FilePath 參數來指定檔案。






範例 2

C:\PS>get-authenticodesignature test.ps1, test1.ps1, sign-file.ps1, makexml.ps1

描述
-----------
這個命令會在命令列所列出的四個檔案中取得 Authenticode 簽章的相關資訊。在此命令中,省略了選擇性的 FilePath 參數名稱。






範例 3

C:\PS>get-childitem $pshome\*.* | foreach-object {Get-AuthenticodeSignature $_} | where {$_.status -eq "Valid"}

描述
-----------
這個命令會列出 $pshome 目錄中具有有效 Authenticode 簽章的所有檔案。$pshome 自動變數包含 Windows PowerShell 安裝目錄的路徑。

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

此命令使用管線運算子 (|),將 $pshome 中的檔案傳送給 Foreach-Object Cmdlet,後者會針對每個檔案呼叫 Get-AuthenticodeSignature。

Get-AuthenticodeSignature Command 的結果會傳送給 Where-Object 命令,後者只會選取具有「有效」狀態的簽章物件。






請參閱




目錄