question

Filip-2434 avatar image
0 Votes"
Filip-2434 asked IanXue-MSFT edited

Start powershell with commands

Hello Everybody.

I want start in powerhsell new powershell window but i want also that window will execute some command rigth when they show up.
I tried somethnig as : "start powershell "dir"
but when i execute it the window still quit.
Can somebody help me?
Thanks for answare.

windows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered IanXue-MSFT edited

Hi,

You can add the "-NoExit" switch to "-ArgumentList".

 Start-Process powershell -ArgumentList "-NoExit","-Command dir"

Best Regards,powerse
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.