46

Is there a way to run a Powershell Prompt with Elevated privileges from a command linein Server 2012?

Problem is this is 'Minimal Server Interface' mode without full server-gui installed so I can run powershell from only either the command prompt or from ServerManager.

I am actually trying to run the command: Enable-ServerManagerStandardUserRemoting but although this appears to work it does not add the user in question to the various groups as it is supposed to do. I suspect it is not working properly because I am not running it from a fully elevated powershell prompt, just a standard prompt but as Administrator.

Thanks, Nick

2 Answers 2

61

Sure... works on Windows 7+, too.

Open Powershell first:

Type PowerShell to enter a PowerShell session.

Once in the session:

Type Start-Process PowerShell -Verb RunAs and press Enter.

That will open a new Powershell process as Administrator.

------- OR -------

To do it all with only one line from the command prompt, just type:

powershell -Command "Start-Process PowerShell -Verb RunAs"

5
  • Thanks, that probably worked. Enable-ServerManagerStandardUserRemoting still doesn't add the user to the groups but at least that rules out any lack of elevation problem. Commented Jan 8, 2013 at 16:15
  • I've never messed with that command...but I'm guessing you already looked here for details? technet.microsoft.com/library/jj205470 Commented Jan 8, 2013 at 17:14
  • 2
    you can shorten it a bit, and you don't need any caps: start powershell -verb runas Commented May 26, 2021 at 15:58
  • This is weird and impossible to remember, probably I need to use an alias to shorten it, but still weird. I expected this to be only a one word command like sudo on Linux. Probably because Windows mostly assumes that users will use its GUI based solutions? Commented Jun 30, 2022 at 18:19
  • 1
    @aderchox - sure, you can easily create a function as part of your local powershell profile and just call it whenever. Most don't need this, if you already have the GUI then launching powershell as administrator is simple enough already. Commented Jul 5, 2022 at 12:38
1

An alternative method is to do the following:

  1. type: runas /user:admin username powershell
  2. enter the appropriate password when prompted

You're done!

3
  • 2
    if you're going to use runas.exe, the first step is unnecessary, just run it from cmd.exe Commented Feb 18, 2015 at 15:08
  • 1
    The difference here is mine was simply to run it elevated, not to run it as a different user. If you try mine out you'll see that you aren't prompted for additional credentials, it simply creates a new elevated shell. Yours is more for running Powershell as someone else. Commented Feb 18, 2015 at 17:28
  • Mathias - thank you for correcting me, I'm by no means an expert! TheCleaner - Please don't misunderstand, your method is very good. I couldn't get it to work in my Core 2012 server setup but I'm sure it was my fault! So this was the alternative method, I'll edit the answer. Commented Feb 18, 2015 at 18:39

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.