問題タブ [invoke-command]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
windows - PowerShell 経由でリモート デーモン (およびそれだけでなく) プロセスを実行する際の問題
私のスクリプトから、リモートの Windows ボックスでコマンドを実行したいと考えています。だから私は少しグーグルで調べましたが、それを行うための最も一般的で何とか標準的な方法は、と同じプロトコルを使用していると思われるPowerShellのコマンドInvoke-Command
レットを使用することです. したがって、以下はスクリプトから呼び出そうとしたコマンドです(実際には、他の多くの変更も試しましたが、IMOは問題を説明するのに十分です):winrm
winrs
PowerShell -Command "$encpass=ConvertTo-SecureString -AsPlainText mypass -Force;$cred = New-Object System.Management.Automation.PSCredential -ArgumentList myuser,$encpass; Invoke-Command -ComputerName REMOTE_COMPUTER_NAME -Credential $cred -ScriptBlock {<fullcommand>};"
PowerShell -Command "$encpass=ConvertTo-SecureString -AsPlainText mypass -Force;$cred = New-Object System.Management.Automation.PSCredential -ArgumentList myuser,$encpass; Invoke-Command -ComputerName REMOTE_COMPUTER_NAME -Credential $cred -ScriptBlock {Start-Process -FilePath <fullexepath> -ArgumentList <arguments> -Wait -NoNewWindow};"
PowerShell -Command "$encpass=ConvertTo-SecureString -AsPlainText mypass -Force;$cred = New-Object System.Management.Automation.PSCredential -ArgumentList myuser,$encpass;$session=new-PSSession -ComputerName "REMOTE_COMPUTER_NAME" -Credential $cred; Invoke-Command -Session $session -ScriptBlock {<fullcommand>};"
注: スクリプトは で書かれてperl
いますが、IMO ここではスクリプトの言語は問題ではないため、スクリプトからコマンドを呼び出すと想定できます。コマンドはbatch
スクリプトから実行する必要があるため、インタラクティブな操作は必要ないことに注意してください。行動。
したがって、これらのコマンドにはいくつかの問題があり、それらを理解するための助けが必要です。どうぞ:
- タイプ のプロセスを実行できません
configure and run daemon
。configure_server.pl
つまり、リモート ボックス (<fullcommand> = "configure_server.pl <arguments>"
) で実行したい場合、これは何かを実行する必要があります。実行するとすぐに、デーモンとして実行されるはずの を含む完全なリモート ジョブが強制終了server.exe
されるため、動作しません。(ポイント 1、2、3 に適用)configure_server.pl
server.exe
- 折り返し (各行の長さが 80 文字以下) の標準出力と標準エラーを取得します。(ポイント 1、3 に適用)
- 標準出力と標準エラーを取得しません。(ポイント 2 に適用)
function - Invoke-Command PowerShell のトラブル
友人の私はこの機能に問題があり、リモートサーバーで実行されますが、次の出力があります:
Invoke-Command : 引数 '& C:\testNunit\dll\' を受け入れる位置パラメーターが見つかりません。At D:\test\Multithread.ps1:65 char:16 + Invoke-Command <<<< -ComputerName $serv -ScriptBlock $command ([ScriptBlock]::Create("& $OneProject")) -credential $cred + CategoryInfo : InvalidArgument: (:) [Invoke-Command]、ParameterBindingException + FullyQualifiedErrorId : PositionalParameterNotFound、Microsoft.PowerShell.Commands.InvokeCommandCommand
powershell - PowerShell でリモート プロセスを開始する方法
問題があります。次のようなスクリプトがあります。
- PSSession に接続します (
PSSession
管理者アカウントで使用します) - 停止 2 プロセス
- それらのファイルを変更してください
- 2プロセスを開始します(ここで問題)
サーバー上で処理を開始したいので、PSSessionで接続しています(問題ありません)
私は Invoke-Command を行います:
しかし、それは何もしません (私は VNC で確認します)
私も Invoke-Command を行います:
プログラムを起動しますが (良い)、私のスクリプトはプログラムの終了を待ちます (良くない)
誰にもアイデアがありますか?
ありがとう