batからps1ファイルを実行する。
batファイルからPowershellファイルを実行する手順を記述します。
test.batファイルの記述は以下の通り。
@echo off
powershell -ExecutionPolicy RemoteSigned -File ./test.ps1
pause自動終了してよいのであれば「pause」は消してよいです。
powershell側は以下のように記載します(テスト用)
Get-ChildItem | Set-Variable ex
Get-ChildItem -Exclude $ex -Recurse |
ForEach-Object{$_.FullName.ToString().Replace($pwd,'')} |
Out-File ./list.txt
echo "finish"
