概要
PowerShellのスクリプトから他のPowerShellのスクリプトを呼び出します。
スクリプト
# - pstest1.ps1 -
./pstest2.ps1 c:\tmp\log\ c:\tmp\output\ chasen.exe
. .\pstest3.ps1
ExecuteCommandToFile chasen.exe c:\tmp\log\ c:\tmp\output\
# - pstest2.ps1 - #パラメータ $cmd = $args[0] $inputDir = $args[1] $outputDir = $args[2] #処理対象ファイルを取得 $files = Get-ChildItem $inputDir -Recurse -include *.txt #入力データフォルダ内のファイルに$cmdを実行し、結果を出力データフォルダへ foreach($f in $files){ $outputFile = Join-Path $outputDir $f.Name &$cmd $f > $outputFile }
# - pstest3.ps1 - function ExecuteCommandToFile($argCmd, $argInputDir, $argOutputDir) { #パラメータ $cmd = $argCmd $inputDir = $argInputDir $outputDir = $argOutputDir #処理対象ファイルを取得 $files = Get-ChildItem $inputDir -Recurse -include *.txt #入力データフォルダ内のファイルに$cmdを実行し、結果を出力データフォルダへ foreach($f in $files){ $outputFile = Join-Path $outputDir $f.Name &$cmd $f > $outputFile } }