2013-04-10 36 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

相關問題