0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

バッチでpowershellを実行する方法

Posted at

バッチでpowershellを実行する方法

基本

powershell -Command ("Get-Alias")

応用

  • for文との組み合わせ
for /f "usebackq" %%i in (powershell -Command("Get-Alias"^)) do (
    echo %%i
)
  • for文との組み合わせ2
for /f "usebackq" %%i in (powershell -Command("Get-Volume | ?{$_.DriveLetter -eq 'C'}"^)) do (
    echo %%i
)

powershellのコマンド内はシングルクォートにするのがミソ

何かあれば追記

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?