PoshCode Archive  Artifact [30337a0b88]

Artifact 30337a0b880f46be54c607d9f0a0d8cee52f677f0b8ad5613133be735e6b3a72:

  • File Get-Set-Signature-CTP2.ps1 — part of check-in [742626ff38] at 2018-06-10 13:39:51 on branch trunk — Wrappers for the Get-AuthenticodeSignature and Set-AuthenticodeSignature which properly parse paths and don’t kill your pipeline and script when you hit a folder by accident… (user: unknown size: 1819)

# encoding: ascii
# api: powershell
# title: Get/Set Signature (CTP2)
# description: Wrappers for the Get-AuthenticodeSignature and Set-AuthenticodeSignature which properly parse paths and don’t kill your pipeline and script when you hit a folder by accident…
# version: 0.1
# type: script
# license: CC0
# x-poshcode-id: 436
# x-derived-from-id: 437
# x-archived: 2009-08-02T06:59:06
#
#
#requires -version 2.0
CMDLET Set-AuthenticodeSignature -snapin Huddled.BetterDefaults {
PARAM ( 
   [Parameter(Position=1, Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
   [Alias("FullName")]
   [ValidateScript({ 
      if((resolve-path .\breaking.ps1).Provider.Name -ne "FileSystem") {
         throw "Specified Path is not in the FileSystem: '$_'" 
      }
      if(!(Test-Path -PathType Leaf $_)) { 
         throw "Specified Path is not a File: '$_'" 
      }
      return $true
   })]
   [string]
   $Path
, 
   $Certificate=$(ls cert:\CurrentUser\my\0DA3A2A2189CD74AE371E6C57504FEB9A59BB22E)
)
   Microsoft.PowerShell.Security\Set-AuthenticodeSignature -Certificate $Certificate -FilePath $Path  
}

CMDLET Get-AuthenticodeSignature -snapin Huddled.BetterDefaults {
PARAM ( 
   [Parameter(Position=1, Mandatory=$true, ValueFromPipelineByPropertyName=$true)]
   [Alias("FullName")]
   [ValidateScript({ 
      if((resolve-path .\breaking.ps1).Provider.Name -ne "FileSystem") {
         throw "Specified Path is not in the FileSystem: '$_'" 
      }
      if(!(Test-Path -PathType Leaf $_)) { 
         throw "Specified Path is not a File: '$_'" 
      }
      return $true
   })]
   [string]
   $Path
)
   Microsoft.PowerShell.Security\Get-AuthenticodeSignature -FilePath $Path  
}

Export-ModuleMember Set-AuthenticodeSignature,Get-AuthenticodeSignature