I tried to sign an old Powershell script with this command:
Set-AuthenticodeSignature 'C:\MyScript.ps1' -cert (get-childitem cert:\currentuser\my\ -codesigningcert)
..but the output was: Unknown Error
This was not the only one that I’ve signed but it’s the only one that I was not able to sign!
After some investigation I discover the problem: the script encoding was “Unicode big endian”. Changed it to UTF-8 I was able to sign it (you can use notepad to change encoding).