2017-09-26 7 views
0

powershellを使用してさまざまなプログラムをインストールしようとする際に問題があります。私は何もしていないようだPowershellコマンドがPSRemote経由で動作しない

Invoke-Command -Session $session -ScriptBlock {TEST-INSTALL-Scripts -Basepath $basepath -Arguments $args} 

コマンドを経由して、それを起動しようとすると

Function TEST-INSTALL-Scripts 
{ 
    Param($basepath,$Arguments) 

    $command = @" 
cmd.exe /C msiexec /package `"$basepath`" $Arguments 
"@ 
    Invoke-Expression -Command $command 
} 

:これは私が構築したモジュールの構成要素の(トリムダウン)の例であります私はいくつかの詳細を取得しようとするPSRemote]タブを使用してみました、私は、このコマンドを使用:

$basepath = "\\$Server\d$\Files\Install\3rd Party\SQL Server Native Client\sqlncli_x64.msi" 
$Arguments = ' /quiet /passive' 
TEST-INSTALL-Scripts -basepath $basepath -Arguments $Arguments 

そして、私は戻って、ファイルが有効なファイルアクセスまたはそのないことはできないと言って応答を取得します。

本発明は、上記のような問題点を解決するためになされたものである。 V e r i f y t h a t t h h e p a c k a g c e s s t s a t s o t c o c c s s i t、o r c o t t t t h h a p p l i c a t e h t t h h i s a a v i l w i n d o w s l l e r p a c k a g e。

マシン自体にRDPを実行すると、まったく同じコマンドが問題なく動作します。

私の研究は、これがダブルホップの問題であることを指摘していますが、ファイルをマシンにコピーするには至りませんでしたが、これは悪夢ではありません。

+1

'-ScriptBlock {TEST-INSTALL-スクリプトを私はまた、管理者にそれを容易にするための機能を内蔵したが、ここでIF文で、私は例を置きます - Basepath $ basepath -Arguments $ args} ' - それは動作しません。 https://stackoverflow.com/q/36328690/478656とhttps://stackoverflow.com/q/40247384/478656とリンクされた質問 – TessellatingHeckler

+1

も参照してください。また、Powershellの 'cmd.exe 'の中で' cmd.exe'をなぜ呼びますか?/C msiexec/package \ '" $ basepath \ '" $ arguments " - >' msiexec/package \ '" $:basepath \ '" $ Arguments " – BenH

+0

@BenH私はcmdを使用しています。 cmdを使用してインストールする必要があります。同じフローを維持する方が簡単です(トリムされたバージョンのみを表示しています)。 – Jewtus

答えて

0

私はインストールパスを通過するリモートコールの直前に配置する最小限の回避策を構築できました。

 If($installPath.StartsWith("\\")) 
     { 
      $DeployPath = Invoke-Command -Session $session -ScriptBlock {$env:TEMP} 
      $drive=(Get-Item $DeployPath).PSDrive.Name 
      $localpath = $DeployPath 
      $DeployPath = $DeployPath.Replace("$($drive):","\\$machine\$drive$") 
      If(!(Test-Path "$DeployPath\3rd Party\Microsoft Visual C++ 2010 Redistributable")) 
      { 
       Copy-Item -Path "$installPath\3rd Party\Microsoft Visual C++ 2010 Redistributable" -Destination "$DeployPath\3rd Party\Microsoft Visual C++ 2010 Redistributable\" -Force -Recurse 
      } 
      If($ODBCDriver){Get-InstallerLocal -installPath $installPath -deployPath $DeployPath -Type "SQL Driver"} 
      $installPath = $localpath 
     } 
(私はタイプに基づいて、同じコピーを行うには、Get-InstallerLocalを建て)
関連する問題