Powershell远程脚本错误CryptAcquireContext期间出错

时间:2014-04-07 14:24:36

标签: powershell

我只是使用invoke-command -computer [servername] -scriptblock {powershell.exe D:\ test \ script.ps1}运行一个简单的脚本

如果我在框中手动运行脚本然后再次运行远程脚本,则不再出现错误,但我不想手动登录到该框并运行脚本以便能够修复此错误特别是有这么多服务器。谁可以帮我这个事。感谢

CryptAcquireContext期间出错。 [服务器名称] : 错误消息:无法完成请求的操作。必须信任计算机以进行委派,并且必须将当前用户帐户配置为允许委派。 错误代码:80090345

在获取错误部分的服务器上运行的脚本

$fciv = "D:\test\fciv.exe"
$fcivLog = "D:\test\fcivLog.txt"
$xmlPath = "D:\test\server.xml"

& $fciv -v -bp "\\servername\folder1" -XML $xmlPath | Out-File $fcivLog

2 个答案:

答案 0 :(得分:0)

这是一个PowerShell函数,可以在PowerShell 2.0版上运行,来计算MD5哈希值:

function Get-MD5FileHash {
    [CmdletBinding()]
    param (
        [string] $Path
    )

    $MD5 = [System.Security.Cryptography.MD5]::Create();
    $Stream = [System.IO.File]::OpenRead($Path);
    $ByteArray = $MD5.ComputeHash($Stream);
    [System.BitConverter]::ToString($ByteArray).Replace('-','').ToLower();
    $Stream.Dispose();
}

Get-MD5FileHash -Path C:\test\test.xlsx;

我在Windows 8.1上的PowerShell 4.0上进行了测试,效果很好!

答案 1 :(得分:0)

这个问题很老了,已经找到解决方法。但是它仍然不能解决使用CryptAcquireContext进行程序委派的主要问题

我在另一个程序(HP的BiosConfigUtility)上也遇到了同样的问题。

我通过允许在我的计算机和远程计算机之间进行委派来解决了该问题。

要在您的客户端上启用委派:

Enable-WSManCredSSP -Role Client -DelegateComputer host.domain.com -Force

要在远程计算机上启用委派:

Enable-WSManCredSSP -Role Server –Force

有关更多信息,请参见此帖子:https://devblogs.microsoft.com/scripting/enable-powershell-second-hop-functionality-with-credssp/