大网数据广告活动
启动与系统组件

SignTool may corrupt PowerShell script file

· 52CE 我爱测

This article provides resolutions for the PowerShell script file corruption that occurs when you use SignTool to sign the file that already contains a digital signature.

Applies to:   Windows SDK for Windows 10

Symptoms

Assume that you made changes to a Windows PowerShell script file (.ps1) that already has a digital signature. The script file may be corrupted after using SignTool (SignTool.exe) to add a new signature.

Cause

When using SignTool to sign a script file for the first time, a carriage return and a line feed are added at the end of the file before the signature is added. When using SignTool to add a new signature to the file, the old signature and the two characters before the signature are deleted. SignTool may corrupt the script if the two characters before the signature are not the carriage return and line feed characters added when the script was signed. This can occur when editing the script file after it has been signed using an editor that replaces carriage return and line feed pairs with a line feed character.

Workaround

Remove the existing signature before signing the file.

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors (upstream author metadata: aartig13). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 06/11/2025
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。