2017-09-13 20 views
0

ユーザー "nt authority \ system"としてPowerShellスクリプトを起動し、スクリプトの出力をファイルにリダイレクトする必要があります。仕事をしておならので、私はPsExec.exe
私のコードを使用するシステム・ユーザーとしてPowerShellを起動するには:ローカルシステムユーザーとしてPowerShellスクリプトを起動し、スクリプト出力をリダイレクト

$Arguments = "-i -s Powershell.exe -File C:\temp\SetupNlb.ps1" 
Start-Process "C:\temp\PsExec.exe" -Wait -ArgumentList $Arguments 

ことは今は動作しません出力のリダイレクトを使用してコード:

$Arguments = "-i -s Powershell.exe -File C:\temp\SetupNlb.ps1 *> C:\temp\SetupNlb.log" 
Start-Process "C:\temp\PsExec.exe" -Wait -ArgumentList $Arguments 

は問題がある可能性がありPowershell.exeの-Fileパラメータは最後のパラメータにする必要がありますが、私は出力/ストリームのリダイレクトも考えています。

+1

リダイレクトはシェルの機能であり、PsExecの機能ではありません。 –

答えて

0

これは機能します。代わりにこれを行うことはできますか?

C:\temp\PsExec.exe -i -s powershell.exe -Command "c:\temp\SetupN1b.ps1 *> c:\temp\SetupN1b.log" 
+0

はい、完璧です、ありがとう! – beniwa

関連する問題