user3112598
user3112598

Reputation: 25

Unable to execute multi-command in power shell

I'm working on power shell script using windows 2012 server, that do simple two functions

the code is:

powershell -Command "& {powershell Start-Process PowerShell -Verb RunAs; Set-Location C:\}

the problem is not when execute the first part, it's in the other part which is:

Set-Location C:\}

My question is there any way after running powershell as administrator execute the next command ?

I already tried to use semicolon ";" but no luck

Upvotes: 0

Views: 84

Answers (1)

sha
sha

Reputation: 17860

If you want to change directory for the process you're spawning - use -WorkingDirectory option:

powershell -Command "& { Start-Process PowerShell -Verb RunAs -WorkingDirectory 'D:' }"

Upvotes: 1

Related Questions