Save the output of a powershell command in a variable and use it in batch script?

后端 未结 2 564
一生所求
一生所求 2021-01-04 14:04

What I am trying to do is to save the output of a powershell command (run from a batch script) and use it in the batch script.

Can you please advise me what to do?

2条回答
  •  孤独总比滥情好
    2021-01-04 14:39

    for /f "tokens=*" %%i in ('powershell /command "[System.Net.Dns]::GetHostByName((hostname)).HostName"') do set return=%%i
    echo %return%
    

提交回复
热议问题