1

リモート コンピューターからプログラムをアンインストールしたいと考えています。インストールに使用された MSI の場所はわかっています。これはリモート サーバー上にあり、パスは$MSIPathFile以下の変数で確認できます。

次のスクリプトを実行すると:

$TargetServer = "d-vasbiz01"
$MSIPathFile = "c:\biztalkdeployment\x.Int.MIS-3.0.0.msi"

Invoke-Command -Computer $TargetServer -ScriptBlock {Param($MSIPathFile, $UninstallFlag, $QuietFlag) Start-Process msiexec.exe "/x" $MSIPathFile "/qn"} -ArgumentList "$MSIPathFile", "/x", "/qn"

次のエラーが表示されます。

Invoke-Command -Computer $TargetServer -ScriptBlock {Param($MSIPathFile, $UninstallFlag, $QuietFlag) Start-Process msiexec.exe "/x" $MSIPathFile "/qn"} -ArgumentList "$MSIPathFile", "/x", "/qn"
A positional parameter cannot be found that accepts argument 'c:\biztalkdeployment\x.Int.MIS-3.0.0.msi'.
+ CategoryInfo          : InvalidArgument: (:) [Start-Process], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartProcessCommand

誰かが私が間違っていることを教えてもらえますか?

4

2 に答える 2

6

これは私の質問に対する答えではありませんが、MSI をリモートでアンインストールするという私の問題は解決します。過去 3 時間さまざまなテクニックを試してきたので、これが誰かの役に立てば幸いです。

これは 1 行のコードで実現できることがわかりました。

(Get-WmiObject -Class Win32_Product -Filter "Name='x.Int.MIS for BizTalk 2010 3.0.0'" -ComputerName $TargetServer ).Uninstall()

次の Technet ページの厚意による: http://technet.microsoft.com/en-us/library/dd347651.aspx

于 2012-08-07T14:59:55.737 に答える
1

返信途中でPCがクラッシュしたので編集が遅くなりすみません。

問題は、開始 Start-Process が変数を展開してコマンドで実行していないように見えることです。したがって、それを機能させるために私が行うことは、実行可能ファイルへのパスを含む文字列を作成し、次に使用したいパラメーターへの別のパスを作成することです。次に、Invoke-expression コマンドを使用して実行します。以下に例を示します。コードを編集できますが、例と説明が好きかもしれません。

$MSIPathFile = "c:\biztalkdeployment\x.Int.MIS-3.0.0.msi"


$msiexec = "C:\Windows\System32\msiexec.exe"
$arguments = '/x' + $MSIPathFile + " /qn"
Invoke-Expression  -Command "$msiexec $arguments"
于 2012-08-07T14:45:02.757 に答える