Dear Sir,
I used a script to sign scripts.
Following is the script I used.
## sign-file.ps1
## Sign a file
param([string] $file=$(throw "Please specify a filename."))
$cert = @(Get-ChildItem cert:\CurrentUser\MY -codesigning)[0]
Set-AuthenticodeSignature $file $cert
When I run this script, it will generate the following error:
Get-ChildItem : A parameter cannot be found that matches parameter name 'codesigning'.
At C:\Users\paul\Documents\Documents\WindowsPowerShell\scripts\sign-file.ps1:4 char:46
+ $cert = @(Get-ChildItem cert:\CurrentUser\MY -codesigning)[0]
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-ChildItem], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Set-AuthenticodeSignature : Cannot bind argument to parameter 'Certificate' because it is null.
At C:\Users\paul\Documents\Documents\WindowsPowerShell\scripts\sign-file.ps1:5 char:33
+ Set-AuthenticodeSignature $file $cert
+ ~~~~~
+ CategoryInfo : InvalidData: (:) [Set-AuthenticodeSignature], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.SetAuthenticodeSignatureCommand
When run the same script again, no more error.
Kindly help.
Paul Cheuk