I'm trying to launch a batch file (with administrative mode) in Powershell. I need the output of the batch file to be within the Powershell console.
I'm able to launch the batch file as administrator using
PS> Start-Process "C:\Scripts\Test.bat" -Verb runas
However the output is not in Powershell but command prompt itself.
I've tried the following command to launch the command prompt directly. The result is the same.
PS> powerShell -Command "&{Start-Process 'cmd.exe' /c C:\Scripts\test.bat' -Verb runas}"
If I try the following command:
PS> &C:\Scripts\test.bat
I will be able to run the batch file with the console output but I will not be able to launch it properly because I need the administrative rights.
Is there a way to launch the batch file with administrative rights and see the output in Powershell console as well?