“Unknown Error” Signing Powershell Script

If you’re having trouble signing a Powershell (PS) script because Set-AuthenticodeSignature is inexplicably returning “Unknown Error”, (but it works on a myriad of other scripts) then you may be sitting there scratching various parts of your anatomy, looking for an explanation.

The reason you are seeing an error is because the PS Set-AuthenticodeSignature command cannot sign script files created in the Integrated Scripting Environment (ISE).

Simply recreate the script file with Notepad.exe and you will be able to sign the file just fine. It’s something to do with the file being encoded in big-endian Unicode format (rather than little-endian presumably) which the PS signing process can’t handle.

10 Responses

  1. [...] Sign your Powershell script with the following command. I ran into an issue where I received an “Unknown Error”, but this turned out to be because I had created the script from within the Powershell ISE. This handy blog post helped me out. [...]

  2. hi there
    i’m so happy that i saw this blog. that post was so helpful. thanks again i bookmarked this page.
    are you planning to post similar posts?

  3. Thanks dude. Nearly scratched a hole in myself with this one. Sure enough the ps ide seems to mess up the signing procedure.

  4. I spent almost a day trying to figure this out, thinking it had to be some weird characters in my script. Too bad I didn’t search for it earlier. Thanks for posting this.

  5. Great tip ! I was getting ready to just set the “virus come to me” option on

  6. Thanks mate! I thought I had to debug for hours (as the worst errors are the unknown errors) but your post helped me solve this problem in a minute.

  7. Great! Thanks a lot for this post, it saved hours… :)

  8. I wish I have seen this tip five day (100 hours ago) this is rediculous…why can MS and the PS team let you know about these quarks in advance….this is so frustrating!!! It’s silly!!

  9. I did this and I’m still having the same problem! :(

    • 1. Get Notepad+ and install it.

      2. Drag and drop the script file that you are having problems with into Notepad+

      3. Look at the N+ status bar and let us know what it says about the file’s encoding type.

      Does it say ANSI, UCS-2 Big Endian, or something else?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.