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