How to get a returned value from powershell and get it in a batch file?

前端 未结 5 836
我在风中等你
我在风中等你 2021-02-06 10:19

I\'m trying to execute a powershell from a batch file with the commande: Powershell .\\nameoffile.ps1

The PowerShell returns some values 1, 4, 0 and -1 . How can I get t

5条回答
  •  日久生厌
    2021-02-06 10:31

    If you need to use this value in your bat environment use FOR /F :

    @echo off
    for /f "delims=" %%a in ('powershell .\test.ps1') do Set "$Value=%%a"
    
    Echo Value received from Powershell : %$Value%
    

提交回复
热议问题