Set-AuthenticodeSignature fails to release file handle after error
When attempting to use Set-AuthenticodeSignature to sign an unsupported file type, such as a .txt file with unstructured text, the cmdlet throws an error as expected, but then the PowerShell host process holds open a handle to that file, preventing the file from being deleted or edited. The PowerShell host process must be terminated to close the handle, or another external tool, like Process Hacker, must be used to close the handle manually.
The error thrown is:
"Status: UnknownError; StatusMessage: The form specified for the subject is not one supported or known by the specified trust provider"
The problem was observed on Windows 10 Pro version 10.0.14393, using PowerShell version 5.1.14393.953.
The open file handle can be seen using Sysinternals handle.exe or with Process Hacker.