0
我試圖在遠程計算機上運行以下命令來卸載先前版本的產品,然後再安裝另一個版本。這是使用MsiExec.exe進行卸載。當在遠程計算機上調用啓動進程「MsiExec.exe」時出現PSRemotingTransportException
每當我打電話給啓動過程,該過程實際上運行,產品在遠程計算機上卸載,但我得到下面的異常拋出。如果產品尚未安裝且啓動過程行不運行,則遠程命令可正常工作,不會引發異常。 (即它實際上搜索註冊表,沒有找到產品,並且返回-1而不會引發異常)只有在調用Start-Process時纔會出現問題。
這裏是我的腳本代碼...
$UninstallScriptBlock = {
param ([string]$InstallerProductName)
$ErrorActionPreference = "Stop";
$UninstallRegPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
$ProductCode = Get-ChildItem -Path $UninstallRegPath | foreach { if ($_.GetValue("DisplayName") -eq $InstallerProductName) { [System.IO.Path]::GetFileName($_); } }
if ([string]::IsNullOrEmpty($ProductCode))
{
$UninstallRegPath = "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall";
$ProductCode = Get-ChildItem -Path $UninstallRegPath | foreach { if ($_.GetValue("DisplayName") -eq $InstallerProductName) { [System.IO.Path]::GetFileName($_); } }
}
if ([string]::IsNullOrEmpty($ProductCode))
{
return -1;
}
$Process = Start-Process -Wait -Passthru -FilePath "MsiExec.exe" -ArgumentList "/X", $ProductCode, "/qn";
return $Process.ExitCode;
}
[int]$UninstallReturnCode = Invoke-Command -ComputerName $Server -ScriptBlock $UninstallScriptBlock -ArgumentList $InstallerProductName -SessionOption (New-PSSessionOption -OperationTimeout 0);
而拋出的異常...
Processing data for a remote command failed with the following error message: The I/O operation has been aborted because of either a thread exit or an application request. For more information, see the about_Remote_Troubleshooting Help topic.
At [Undisclosed]
+ [int]$UninstallReturnCode = Invoke-Command -ComputerName $Server -ScriptBloc ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: ([UndisclosedServerName]:String) [], PSRemotingTransportException
+ FullyQualifiedErrorId : JobFailure
+ PSComputerName : [UndisclosedServerName]
而格式化的錯誤...
ErrorCode : 995
TransportMessage : The I/O operation has been aborted because of either a thread exit or an application request.
ErrorRecord : Processing data for a remote command failed with the following error message: The I/O
operation has been aborted because of either a thread exit or an application request. For
more information, see the about_Remote_Troubleshooting Help topic.
StackTrace :
WasThrownFromThrowStatement : False
Message : Processing data for a remote command failed with the following error message: The I/O
operation has been aborted because of either a thread exit or an application request. For
more information, see the about_Remote_Troubleshooting Help topic.
Data : {}
InnerException :
TargetSite :
HelpLink :
Source :
如果在異常之後執行「$ Error [0] .Exception | Format-List * -Force」,您會得到什麼? – 2013-03-06 07:43:57
添加格式化的錯誤發佈。 – TylerOhlsen 2013-03-06 14:41:22
我想我已經發現了這個問題。我認爲我的安裝程序正在重置IIS,從而導致我的Powershell遠程連接被切斷。這聽起來可行嗎? – TylerOhlsen 2013-03-06 19:25:21