以下の内容はhttps://htn20190109.hatenablog.com/entry/2023/04/15/201303より取得しました。


{PowerShell}OSコマンド実行

 


https://win.just4fun.biz/?PowerShell/%E6%96%87%E5%AD%97%E5%88%97%E3%82%92%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%A8%E3%81%97%E3%81%A6%E5%AE%9F%E8%A1%8C%E3%81%99%E3%82%8B%E3%83%BBInvoke-Expression

 

想定シナリオ:
ファイルからコマンドを取得して実行し、結果をファイルに書き込む

# テスト用ファイル作成

$f1 = "H:\tmp\a.txt"
$f2 = "H:\tmp\a.log"

Write-Output 'mysql -uroot -p"password" -D test --skip-column-names -e "select now();"' | Out-File -FilePath $f1
Write-Output 'mysql -uroot -p"password" -D test --skip-column-names -e "show tables;"' | Out-File -FilePath $f1 -Append
Write-Output 'mysql -uroot -p"password" -D test --skip-column-names -e "show create table tab1 \G"' | Out-File -FilePath $f1 -Append

Get-Content -Path $f1


# OSコマンド実行

Get-Content -Path $f1 | Invoke-Expression | Set-Content $f2

 




以上の内容はhttps://htn20190109.hatenablog.com/entry/2023/04/15/201303より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14