Introduction

When using Powershell, you may need to run an elevated Powershell window to perform a specific task or run a script.

The reason for this is the User Account Control (UAC). Introduced with Windows Vista User Account Control (UAC) keeps the user in a non-elevated state if not explicitly told to be elevated as an administrator. Some scripts and CMDlets in Powershell require you to run with the highest privileges to change the system.

To read more about how the User Account Control (UAC) works in Windows 10, refer to https://docs.microsoft.com/en-us/windows/security/identity-protection/user-account-control/how-user-account-control-works.

This blog post describes how to elevate to an administrator in Powershell.

For learning more about Powershell, I recommend signing up and using Pluralsight!

Which Powershell actions require elevation?

There are some actions in Powershell which require you to elevate, such as:

  • Changing of the Execution Policy
  • Modifications to System Files
  • Modifications of the Registry

It is best practice always to start an elevated Powershell window to not run into any unexpected issues.

The only time I would not recommend this if you are testing a script intending to run as a regular user.

How to elevate Powershell to admin

There are several alternatives for elevating your Powershell command prompt.

Here are three options:

  • Elevate Powershell to an administrator through Windows Search
  • Create a new task in Task Manager
  • Use the runAs command in Powershell

Alternative #1 – Elevate Powershell to admin through Windows Search

The easiest way to start elevated Powershell windows is by searching for the Powershell application.

Press the Windows button to open the start menu and type Powershell. Select Run as administrator to launch run a Powershell window with full privileges.

Start Powershell as administrator using the start menu in Windows 10

Press Yes in the UAC prompt, and you are good to go!

Alternative #2 – Create a new task in Task Manager

Press the Windows button and search for Task Manager.

Press File and Create a new task

Enter PowerShell and check Create this task with administrative privileges

Start an elevated Powershell window from the Task Manager
Start elevated Powershell window from the Task Manager

Alternative #3 – Use the runAs command in Powershell

Run the following command from a non-elevated Powershell prompt:

Start-Process Powershell -Verb runAs

If prompted by the UAC, enter the administrative credentials.

There are now two Powershell windows, one elevated to an administrator and one not elevated to an administrator.

Use Start-Process to start an elevated Powershell window

Conclusion

I hope you have found one way of opening Powershell as an administrator user. How do you elevate to an administrator? Please leave a comment below! 🙂

For learning more about Powershell, I highly recommend the courses provided by Pluralsight.

References

Further learning

4 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here