2013-04-10 35 views
2

我想从PowerShell中解压7za.exe(独立版本的7-zip)存档。基本上,条带化的所有服务的代码,我的尝试是这样的:从PowerShell运行控制台EXE:在本地和远程会话输出中的不同行为

[string]$pathTo7z = "$env:TEMP\7za.exe" 
    [Array]$arguments = "x", $dist, "-o$targetDir" 

    & $pathTo7z $arguments 2>&1 

$dist是ZIP文件的本地路径。 $targetDir是本地目录的完整路径。

如果我运行它,我的意思是,本地,没有任何远程参与,我得到7za.exe的输出没有问题。这跟我从cmd.exe运行它一样。现在

,问题弹出,如果我在远程会话中运行它:

.... 
Invoke-Command -Session $s -ScriptBlock { 
    .... 
    [string]$pathTo7z = "$env:TEMP\7za.exe" 
    [Array]$arguments = "x", $dist, "-o$targetDir" 

    & $pathTo7z $arguments 2>&1 
} 

当然,我要确保远程PC上存在7za.exe等,所以,当我运行它这样,我看到一个非常奇怪的行为。它可以显示7za.exe的一些输出,然后挂起。后的一段时间(时间足够长,相比于以提取150 MB拉链所需的时间)其输出如下:

WARNING: The network connection to MyServer has been interrupted. Attempting to reconnect for up to 4 minutes... 
WARNING: Attempting to reconnect to MyServer ... 
WARNING: The network connection to MyServer has been restored. 

有时恢复运行并输出多一些。但更多的时候它不能完成它的工作并失败,出现以下错误:

Processing data for a remote command failed with the following error message: The WinRM client cannot process the request. The encrypted 
message body has an invalid format and cannot be decrypted. Ensure that the service is encrypting the message body according to the 
specifications. For more information, see the about_Remote_Troubleshooting Help topic. 
    + CategoryInfo   : OperationStopped: (MyServer:String) [], PSRemotingTransportException 
    + FullyQualifiedErrorId : JobFailure 
    + PSComputerName  : MyServer 

那是什么?我应该怎么做,以获得控制台EXE输出,就像我在本地运行时一样?

回答

1

同样,它证明是ESET NOD32防病毒软件。只需按照here中描述的步骤操作即可。那篇文章

摘录:

My recommended way of resolving this issue is to add exceptions for PowerShell and the PowerShell ISE under Protocol filtering > Excluded Applications:

enter image description here

+0

太多的防病毒程序伤害比他们更帮助。 – alroc 2013-12-11 13:46:04

+0

呃...我们只注意到它受伤的时候,但它可能也会帮助很多:) – 2013-12-11 13:53:28

相关问题