Reputation: 129
i want to do following steps in power shell:- Step 1.) Open Administrative Command prompt from power shell. Step 2.) Execute some command on that administrative command prompt opened in step 1. Step 3.) Capture the output of the command executed in step 2. Step 4.) Close Administrative command prompt opened in step 1.
after much google and searching i am not able to find the exact power shell command required to achieve the above task. Please tell if the above is possible, if yes then how?
Upvotes: 2
Views: 14938
Reputation: 26150
one possible way (replace echo test with your commands)
$prog="cmd.exe"
$params=@("/C";"echo test";" >c:\temp\result.txt")
Start-Process -Verb runas $prog $params
gc c:\temp\result.txt
Upvotes: 3