Knowledge Base

Preserving for the future: Shell scripts, AoC, and more

Run as admin Powershell window, run as other user

So if you've already entered credentials to run a Powershell window as a different user, but you still need to run an elevated, i.e., run-as-administrator, prompt, you can type this command in.

Start-Process powershell -Verb RunAs

Alternative

But if you've not done anything yet, and want to open a cmd.exe prompt (notably, not Powershell!) to then kick off such a process:

%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -Command Start-Process -Verb RunAsUser $PSHOME\powershell.exe '-NoProfile -Command Start-Process -Verb RunAs \\\"$PSHOME\powershell.exe\\\"'; Start-Sleep 120

Reference:

  1. https://superuser.com/questions/661979/run-as-different-user-and-elevate

Comments