Get-AuthenticodeSignature
获取有关文件的验证码签名的信息。
语法
ByPath (默认值)
Get-AuthenticodeSignature
[-FilePath] <String[]>
[<CommonParameters>]
ByLiteralPath
Get-AuthenticodeSignature
-LiteralPath <String[]>
[<CommonParameters>]
说明
Get-AuthenticodeSignature cmdlet 获取有关文件的 Authenticode 签名的信息。 如果未对文件进行签名,则会检索信息,但字段为空。
示例
示例 1:获取文件的验证码签名
Get-AuthenticodeSignature -FilePath "C:\Test\NewScript.ps1"
此命令获取有关 NewScript.ps1 文件中的 Authenticode 签名的信息。 它使用 FilePath 参数来指定文件。
示例 2:获取多个文件的验证码签名
Get-AuthenticodeSignature test.ps1, test1.ps1, sign-file.ps1, makexml.ps1
此命令获取有关命令行中列出的四个文件的 Authenticode 签名的信息。 在此示例中,省略 FilePath 参数的名称(可选)。
示例 3:仅获取多个文件的有效验证码签名
Get-ChildItem $PSHOME\*.* | ForEach-object {Get-AuthenticodeSignature $_} | Where-Object {$_.status -eq "Valid"}
此命令列出 $PSHOME 目录中具有有效验证码签名的所有文件。
$PSHOME 自动变量包含 PowerShell 安装目录的路径。
该命令使用 Get-ChildItem cmdlet 来获取 $PSHOME 目录中的文件。
它使用 模式。 排除目录(尽管它还排除文件名中没有点的文件)。
该命令使用管道运算符 (|) 将 $PSHOME 中的文件发送到 ForEach-Object cmdlet,其中为每个文件调用 Get-AuthenticodeSignature。
Get-AuthenticodeSignature 命令的结果将发送到仅选择状态为“有效”的签名对象的 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 中的验证码签名的信息,请参阅 about_Signing。