首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >powershell签名脚本不会在不同的域中运行。

powershell签名脚本不会在不同的域中运行。
EN

Server Fault用户
提问于 2020-10-27 15:42:24
回答 1查看 391关注 0票数 0

因此,我成功地用这个不错的教程https://www.darkoperator.com/blog/2013/3/5/powershell-basics-execution-policy-part-1.html签署了一个powershell脚本,我有一个脚本签名了,它在任何地方都能正常工作,甚至在其他领域也是如此。今天,我使用相同的命令和证书来签署另一个脚本,但是它只运行在相同的域中,没有其他任何地方!在另一个环境中,我得到了这个错误:

代码语言:javascript
复制
.\ITMuninstall.ps1 : File C:\temp\ITMuninstall.ps1 cannot be loaded. The contents of file C:\temp\ITMuninstall.ps1 might have been changed by an unauthorized user or process, because the hash of the file does not match the hash stored in the digital signature. The script cannot run on the specified system. 

我刚刚复制了这个文件,它的字节大小完全相同,那么哈希怎么可能不匹配呢?在我看来,代码中没有特殊的字符。

编辑:file散列检查:在我签名的域中的服务器上,它运行良好:

没有找到PS Microsoft.PowerShell.Core\FileSystem::\tsclient\h\packages> Get-ExecutionPolicy AllSigned PS Microsoft.PowerShell.Core\FileSystem::\tsclient\h\packages> .\ITMuninstall.ps1 KNTCMA_Primary服务..#en1#=‘#en1#2’> Microsoft.PowerShell.Core\FileSystem::\tsclient\h\packages> 8AD1FDA5C8D90FE3E456B9935F0FAE0CD046F0F803C0BEF88BBEC3C484B6AB33 \tsclient\h\包\ITMunin.

在不同域中的另一台服务器上,除非我将执行策略从Allsigned更改为限制较小的(但不能在任何地方执行),否则我无法运行它:

代码语言:javascript
复制
PS Microsoft.PowerShell.Core\FileSystem::\\tsclient\h\packages> .\ITMuninstall.ps1
.\ITMuninstall.ps1 : File \\tsclient\h\packages\ITMuninstall.ps1 cannot be loaded. The contents of file \\tsclient\h\pa
ckages\ITMuninstall.ps1 might have been changed by an unauthorized user or process, because the hash of the file does n
ot match the hash stored in the digital signature. The script cannot run on the specified system. For more information,
 run Get-Help about_Signing..
At line:1 char:1
+ .\ITMuninstall.ps1
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : SecurityError: (:) [], PSSecurityException
    + FullyQualifiedErrorId : UnauthorizedAccess
PS Microsoft.PowerShell.Core\FileSystem::\\tsclient\h\packages> Get-FileHash .\ITMuninstall.ps1

Algorithm       Hash                                                                   Path
---------       ----                                                                   ----
SHA256          8AD1FDA5C8D90FE3E456B9935F0FAE0CD046F0F803C0BEF88BBEC3C484B6AB33       \\tsclient\h\packages\ITMunin...

将文件从UNC路径复制到c:\temp并不重要

EN

回答 1

Server Fault用户

发布于 2020-10-27 16:17:45

需要添加域才能存在现有证书。

导入证书并备份

代码语言:javascript
复制
Import-Certificate -FilePath "C:\Users\proxb\Desktop\BackupCert.Cer" -CertStoreLocation 'Cert:\LocalMachine\My' -Verbose

连接后,使用您选择的工具,您可以检查更多的这里

代码语言:javascript
复制
$Certificate = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 
票数 0
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/1040255

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档